Submission #951349

#TimeUsernameProblemLanguageResultExecution timeMemory
951349quanlt206Cave (IOI13_cave)C++17
100 / 100
259 ms1104 KiB
#include "cave.h" #include<bits/stdc++.h> #define X first #define Y second #define all(x) begin(x), end(x) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define FORD(i, b, a) for(int i = (b); i >= (a); i--) #define REP(i, a, b) for (int i = (a); i < (b); i++) #define mxx max_element #define mnn min_element #define SQR(x) (1LL * (x) * (x)) #define MASK(i) (1LL << (i)) #define Point Vector #define left Left #define right Right #define div Div using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; typedef pair<db, db> pdb; typedef pair<ld, ld> pld; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef pair<ll, ll> pll; typedef pair<ll, pll> plll; typedef pair<ll, int> pli; typedef pair<ll, pii> plii; template<class A, class B> bool maximize(A& x, B y) { if (x < y) return x = y, true; else return false; } template<class A, class B> bool minimize(A& x, B y) { if (x > y) return x = y, true; else return false; } /* END OF TEMPLATE */ const int N = 5e3 + 7; int n, s[N], d[N]; int a[N], b[N]; void subtask_1() { REP(i, 0, n) a[i] = i, b[i] = 0; REP(i, 0, n) { int val = tryCombination(b); if (val > i || val == -1) continue; b[i]^=1; } if (tryCombination(b) != -1) return ; answer(b, a); exit(0); } void subtask_2() { REP(i, 0, n) b[i] = 0; if (tryCombination(b) != -1) return ; REP(i, 0, n) { b[i]^=1; int vcl = tryCombination(b); a[i] = vcl; b[i]^=1; } answer(b, a); exit(0); } void subtask_3() { REP(i, 0, n) b[i] = 0; int tmp = tryCombination(b); while (tmp != -1) { REP(j, 0, n) { b[j]^=1; int vcl = tryCombination(b); if (vcl == -1 || vcl > tmp) { tmp = vcl; break; } b[j]^=1; } } REP(i, 0, n) { b[i]^=1; int vcl = tryCombination(b); a[i] = vcl; b[i]^=1; } answer(b, a); exit(0); } bool hasAns[N]; void subtask_full() { REP(i, 0, n) b[i] = 0, hasAns[i] = false; REP(stt, 0, n) { REP(i, 0, n) if (!hasAns[i]) b[i] = 0; int val = tryCombination(b); int bit = 0; if (!(val == -1 || val > stt)) { bit^=1; REP(i, 0, n) if (!hasAns[i]) b[i]^=1; } vector<int> rem; REP(i, 0, n) if (!hasAns[i]) rem.push_back(i); int d = 0, c = (int)rem.size() - 1, g; while (d < c) { g = (d + c) >> 1; // flip bit tu d -> g FOR(i, d, g) if (!hasAns[rem[i]]) b[rem[i]]^=1; int tmp = tryCombination(b); if (tmp == -1 || tmp > stt) d = g + 1; else { FOR(i, d, c) if (!hasAns[rem[i]]) b[rem[i]]^=1; c = g; } } int idx = rem[d]; a[rem[d]] = stt; hasAns[rem[d]] = true; } answer(b, a); } void exploreCave(int N) { n = N; // if (n <= 100) { // subtask_3(); // return ; // } // subtask_2(); // subtask_1(); subtask_full(); return ; }

Compilation message (stderr)

cave.cpp: In function 'void subtask_full()':
cave.cpp:128:13: warning: unused variable 'idx' [-Wunused-variable]
  128 |         int idx = rem[d];
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...