Submission #2770511


Source Code Expand

Copy
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[1 << 18];
int ret[1 << 18];

int n;
pii big1[1 << 18];
pii big2[1 << 18];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < (1<<n); i++) {
    int t;
    scanf("%d", &t);
    if(i == 0) {
      big1[i] = pii(t, 0);
    }
    else {
      set<pii> all;
      for(int a = 0; a < n; a++) {
        if(i&(1<<a)) {
          all.insert(big1[i ^ (1<<a)]);
          all.insert(big2[i ^ (1<<a)]);
        }
      }
      all.insert(pii(t, i));
      big1[i] = *all.rbegin();
      all.erase(big1[i]);
      big2[i] = *all.rbegin();
      ret[i] = big1[i].first + big2[i].first;
    }
    if(i >= 1) {
      ret[i] = max(ret[i], ret[i-1]);
      printf("%d\n", ret[i]);
    }
  }
}

Submission Info

Submission Time
Task E - Or Plus Max
User xiaowuc1
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1729 Byte
Status AC
Exec Time 323 ms
Memory 9216 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:52:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
./Main.cpp:55:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
                    ^

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 2 ms 4352 KB
sample_02.txt AC 2 ms 4352 KB
sample_03.txt AC 2 ms 4352 KB
subtask_1_01.txt AC 2 ms 4352 KB
subtask_1_02.txt AC 2 ms 4352 KB
subtask_1_03.txt AC 32 ms 4736 KB
subtask_1_04.txt AC 3 ms 4352 KB
subtask_1_05.txt AC 2 ms 4352 KB
subtask_1_06.txt AC 7 ms 4480 KB
subtask_1_07.txt AC 9 ms 4480 KB
subtask_1_08.txt AC 2 ms 4352 KB
subtask_1_09.txt AC 2 ms 4352 KB
subtask_1_10.txt AC 17 ms 4608 KB
subtask_1_11.txt AC 2 ms 4352 KB
subtask_1_12.txt AC 37 ms 4992 KB
subtask_1_13.txt AC 2 ms 4352 KB
subtask_1_14.txt AC 260 ms 9216 KB
subtask_1_15.txt AC 2 ms 4352 KB
subtask_1_16.txt AC 263 ms 9216 KB
subtask_1_17.txt AC 267 ms 7680 KB
subtask_1_18.txt AC 319 ms 9088 KB
subtask_1_19.txt AC 322 ms 9216 KB
subtask_1_20.txt AC 181 ms 9216 KB
subtask_1_21.txt AC 261 ms 9216 KB
subtask_1_22.txt AC 266 ms 9216 KB
subtask_1_23.txt AC 260 ms 9216 KB
subtask_1_24.txt AC 269 ms 7680 KB
subtask_1_25.txt AC 323 ms 9088 KB
subtask_1_26.txt AC 320 ms 9216 KB
subtask_1_27.txt AC 176 ms 9216 KB
subtask_1_28.txt AC 255 ms 9216 KB
subtask_1_29.txt AC 264 ms 9216 KB