제출 #1092189

#제출 시각아이디문제언어결과실행 시간메모리
1092189pubin06동굴 (IOI13_cave)C++14
100 / 100
669 ms796 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; const int MXn = 5005; int n; int ask(int a[]) { int res = tryCombination(a); if (res < 0) res = n; return res; } int ans[MXn], arr[MXn], pos[MXn]; bool ok[MXn]; void exploreCave(int N) { n = N; memset(ans, 0, sizeof ans); for (int i = 0; i < N; i++) { int t = tryCombination(ans) == i ? 0 : 1; int l = 0, r = N - 1, mid, res; while (l <= r) { mid = (l + r) >> 1; for (int i = 0; i < N; i++) { if (ok[i]) arr[i] = ans[i]; else if (i <= mid) arr[i] = 1; } int tmp = ask(arr); if (t) { if (tmp == i) { res = mid; r = mid - 1; } else l = mid + 1; } else { if (tmp > i) { res = mid; r = mid - 1; } else l = mid + 1; } for (int i = 0; i < N; i++) { if (ok[i]) arr[i] = ans[i]; else if (i <= mid) arr[i] = 0; } } ok[res] = true; ans[res] = t ^ 1; pos[res] = i; } answer(ans, pos); }

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:46:18: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |         pos[res] = i;
      |         ~~~~~~~~~^~~
#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...