Submission #3240147


Source Code Expand

#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> a(1<<n);
		REP(i, 1<<n) {
			cin >> a[i];
		}

		using P = pair<LL, int>;
		vector<vector<P>> dp(1<<n);

		REP(k, 1<<n) {
			dp[k].emplace_back(a[k], k);
			REP(i, n) {
				if((k>>i)&1) {
					for(auto&& e : dp[k^(1<<i)]) {
						dp[k].emplace_back(e);
					}
				}
			}
			sort(ALL(dp[k]));
			reverse(ALL(dp[k]));
			dp[k].erase(unique(ALL(dp[k])), dp[k].end());
			dp[k].resize(2);
		}

		REP(k, 1<<n) {
			dpite(ALL(dp[k]));
		}
		
		LL ma = -1;
		FOR(i, 1, 1<<n) {
			chmax(ma, dp[i][0].F + dp[i][1].F);
			cout << ma << endl;
		}

	}
	return 0;
}

Submission Info

Submission Time
Task E - Or Plus Max
User sntea
Language C++14 (GCC 5.4.1)
Score 700
Code Size 3813 Byte
Status AC
Exec Time 344 ms
Memory 130688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 35
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 35 ms 14208 KB
subtask_1_04.txt AC 2 ms 512 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 7 ms 3328 KB
subtask_1_07.txt AC 8 ms 3328 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 1 ms 256 KB
subtask_1_10.txt AC 16 ms 6784 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 29 ms 14336 KB
subtask_1_13.txt AC 1 ms 384 KB
subtask_1_14.txt AC 341 ms 130688 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 339 ms 130688 KB
subtask_1_17.txt AC 342 ms 129152 KB
subtask_1_18.txt AC 271 ms 130560 KB
subtask_1_19.txt AC 272 ms 130688 KB
subtask_1_20.txt AC 272 ms 130688 KB
subtask_1_21.txt AC 339 ms 130688 KB
subtask_1_22.txt AC 342 ms 130688 KB
subtask_1_23.txt AC 339 ms 130688 KB
subtask_1_24.txt AC 344 ms 129152 KB
subtask_1_25.txt AC 279 ms 130560 KB
subtask_1_26.txt AC 273 ms 130688 KB
subtask_1_27.txt AC 274 ms 130688 KB
subtask_1_28.txt AC 338 ms 130688 KB
subtask_1_29.txt AC 339 ms 130688 KB