Submission #2774156


Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n,l;
int a[277777];
pair<int,int> fm[277777],sm[277777];//num,pos
int main()
{
	scanf("%d",&n);l=1<<n;
	for(int i=0;i<l;i++)scanf("%d",&a[i]);
	int ans=0;
	for(int i=0;i<l;i++)
	{
		fm[i]=make_pair(a[i],i);sm[i]=make_pair(0,0);
		for(int b=0;b<n;b++)
		{
			if(i&(1<<b))
			{
				int x=i-(1<<b);
				if(fm[x]>fm[i])
				{
					sm[i]=max(sm[i],fm[i]);
					fm[i]=fm[x];
				}
				if(fm[x]>sm[i]&&fm[x].second!=fm[i].second)
				{
					sm[i]=fm[x];
				}
				if(sm[x]>sm[i]&&sm[x].second!=fm[i].second)
				{
					sm[i]=sm[x];
				}
			}
		}
		ans=max(ans,fm[i].first+sm[i].first);
		if(i)printf("%d\n",ans);
	}
	return 0;
}

Submission Info

Submission Time
Task E - Or Plus Max
User Suika_predator
Language C++14 (GCC 5.4.1)
Score 700
Code Size 799 Byte
Status AC
Exec Time 100 ms
Memory 8320 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);l=1<<n;
                ^
./Main.cpp:15:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<l;i++)scanf("%d",&a[i]);
                                       ^

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 2304 KB
sample_02.txt AC 1 ms 2304 KB
sample_03.txt AC 1 ms 2304 KB
subtask_1_01.txt AC 2 ms 2304 KB
subtask_1_02.txt AC 2 ms 2304 KB
subtask_1_03.txt AC 11 ms 2816 KB
subtask_1_04.txt AC 2 ms 2304 KB
subtask_1_05.txt AC 2 ms 2304 KB
subtask_1_06.txt AC 4 ms 2432 KB
subtask_1_07.txt AC 4 ms 2432 KB
subtask_1_08.txt AC 2 ms 2304 KB
subtask_1_09.txt AC 1 ms 2304 KB
subtask_1_10.txt AC 6 ms 2560 KB
subtask_1_11.txt AC 1 ms 2304 KB
subtask_1_12.txt AC 11 ms 3072 KB
subtask_1_13.txt AC 2 ms 2304 KB
subtask_1_14.txt AC 100 ms 8320 KB
subtask_1_15.txt AC 1 ms 2304 KB
subtask_1_16.txt AC 96 ms 8320 KB
subtask_1_17.txt AC 84 ms 6784 KB
subtask_1_18.txt AC 80 ms 8192 KB
subtask_1_19.txt AC 80 ms 8320 KB
subtask_1_20.txt AC 84 ms 8320 KB
subtask_1_21.txt AC 96 ms 8320 KB
subtask_1_22.txt AC 99 ms 8320 KB
subtask_1_23.txt AC 94 ms 8320 KB
subtask_1_24.txt AC 86 ms 6784 KB
subtask_1_25.txt AC 80 ms 8192 KB
subtask_1_26.txt AC 80 ms 8320 KB
subtask_1_27.txt AC 83 ms 8320 KB
subtask_1_28.txt AC 95 ms 8320 KB
subtask_1_29.txt AC 97 ms 8320 KB