제출 #311788

#제출 시각아이디문제언어결과실행 시간메모리
311788saarang123동굴 (IOI13_cave)C++14
13 / 100
36 ms512 KiB
#include "cave.h" void exploreCave(int n) { int a[n], s[n], d[n]; for(int i = 0; i < n; i++) a[i] = 0, s[i] = 0, d[i] = -1; int x = tryCombination(a); while(x != -1) { int id, k; int mn = 0, mx = n - 1; while(mn < mx) { int mid = (mn + mx) >> 1; //cout << "Binsearch: " << mn << " " << mid << " " << mx << endl; for(int i = mn; i <= mid; i++) if(d[i] == -1) a[i] ^= 1; k = tryCombination(a); for(int i = mn; i <= mid; i++) if(d[i] == -1) a[i] ^= 1; if(k != x) mx = mid; else mn = mid + 1; } id = mn; //cout << "Binsearch end: " << id << " k: " << k << endl; cout << endl; if(k < x && k > -1) d[id] = k; else d[id] = x, a[id] ^= 1; x = tryCombination(a); } for(int i = 0; i < n; i++) s[i] = a[i]; //answer(s, d); for(int i = 0; i < n; i++) { if(d[i] != -1) continue; s[i] ^= 1; d[i] = tryCombination(s); s[i] ^= 1; } answer(s, d); }

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:26:35: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |         if(k < x && k > -1) d[id] = k;
      |                             ~~~~~~^~~
#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...