제출 #736341

#제출 시각아이디문제언어결과실행 시간메모리
736341jk410드문 곤충 (IOI22_insects)C++17
47.50 / 100
273 ms508 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int n; bool used[2000]; int mySolve[2001]; int solve(int x) { int& ret = mySolve[x]; if (ret != -1) return ret; for (int i = 0; i < n; i++) { move_inside(i); used[i] = true; if (press_button() > x) { used[i] = false; move_outside(i); } } ret = 0; for (int i = 0; i < n; i++) { if (used[i]) { ret++; move_outside(i); } } return ret; } int min_cardinality(int _n) { n = _n; memset(mySolve, -1, sizeof(mySolve)); int cnt = solve(1); int l = 1, r = n / cnt, ans; while (l <= r) { int m = (l + r) >> 1; if (solve(m) == cnt * m) { ans = m; l = m + 1; } else r = m - 1; } return ans; }

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

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:42:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |  return ans;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...