Submission #415527

#TimeUsernameProblemLanguageResultExecution timeMemory
415527Pro_ktmrCave (IOI13_cave)C++17
100 / 100
407 ms460 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) #define repi(i, a, b) for(int (i)=(a); (i)<(b); (i)++) #include "cave.h" // int tryCombination(int S[]) // void answer(int S[], D[]) namespace { int s[5000], S[5000], D[5000]; void turn(int l, int r){ repi(i, l, r){ if(S[i] == -1) s[i] ^= 1; } } } void exploreCave(int N) { rep(i, N){ S[i] = -1; s[i] = 0; D[i] = -1; } rep(i, N - 1){ int res = tryCombination(s); if(res != i) turn(0, N); int l = 0, r = N; while(r - l > 1){ int m = (l + r) / 2; turn(l, m); int res = tryCombination(s); if(res == i) l = m; else{ turn(l, m); r = m; } } turn(l, r); S[l] = s[l]; D[l] = i; } rep(i, N) if(D[i] == -1){ int res = tryCombination(s); if(res == N - 1) S[i] = s[i] ^ 1; else S[i] = s[i]; D[i] = N - 1; break; } answer(S, D); }

Compilation message (stderr)

cave.cpp: In function 'void {anonymous}::turn(int, int)':
cave.cpp:5:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define repi(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
      |                               ^
cave.cpp:14:9: note: in expansion of macro 'repi'
   14 |         repi(i, l, r){
      |         ^~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
      |                           ^
cave.cpp:21:5: note: in expansion of macro 'rep'
   21 |     rep(i, N){
      |     ^~~
cave.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
      |                           ^
cave.cpp:26:5: note: in expansion of macro 'rep'
   26 |     rep(i, N - 1){
      |     ^~~
cave.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
      |                           ^
cave.cpp:44:5: note: in expansion of macro 'rep'
   44 |     rep(i, N) if(D[i] == -1){
      |     ^~~
#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...