Submission #52126

#TimeUsernameProblemLanguageResultExecution timeMemory
52126rondojimCave (IOI13_cave)C++17
13 / 100
35 ms512 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; const int MAXN = 5e3 + 5; int st[MAXN], con[MAXN], cnt, n, SS[MAXN], DD[MAXN]; /* int tryCombination(int S[]){ int mn = MAXN; for(int i=0; i<n; ++i) if(S[i] != SS[i]) mn = min(mn, DD[i]); return mn == MAXN ? -1 : mn; } */ /* void answer(int S[], int D[]){ bool ok = true; for(int i=0; i<n; ++i) if(S[i] != SS[i]) ok = false; for(int i=0; i<n; ++i) if(D[i] != DD[i]) ok = false; puts(ok ? "YES" : "NO"); } */ void solve(int ret){ int lo = 0, hi = n - 1, mid, res, r; while(lo <= hi){ mid = (lo + hi)>>1; for(int i=0; i<=mid; ++i) st[i] ^= 1; r = tryCombination(st); for(int i=0; i<=mid; ++i) st[i] ^= 1; if(r != ret) hi = mid - 1, res = mid; else lo = mid + 1; } st[res] ^= 1; } void exploreCave(int N){ n = N; while(true){ int ret = tryCombination(st); if(ret == -1){ for(int i=0; i<n; ++i){ st[i] ^= 1; con[i] = tryCombination(st); st[i] ^= 1; } break; } solve(ret); } answer(st, con); } /* int main(){ scanf("%d", &n); for(int i=0; i<n; ++i) scanf("%d", &SS[i]); for(int i=0; i<n; ++i) scanf("%d", &DD[i]); exploreCave(n); return 0; } */

Compilation message (stderr)

cave.cpp: In function 'void solve(int)':
cave.cpp:35:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  st[res] ^= 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...