제출 #291897

#제출 시각아이디문제언어결과실행 시간메모리
291897BertedColors (BOI20_colors)C++14
0 / 100
0 ms256 KiB
#include <iostream> #include <set> #include <assert.h> #define ll long long using namespace std; ll n; inline bool ask(ll x) { bool ret; assert(1 <= x && x <= n); cout << "? " << x << endl; cin >> ret; return ret; } int main() { int t; cin >> t; while (t--) { cin >> n; ll s = 0, c = 0, L = 1, R = n - 1; for (int i = 0; L <= R; i++) { ll M = (R - L + 1 > 2) ? (L + R >> 1) : R; if (i & 1) {c -= M;} else {c += M;} s = min(s, c); L = M + 1; } s = -s + 1; L = 1, R = n - 1; ll ans = n; if (n > 1) ask(s); for (int i = 0; L <= R; i++) { ll M = (R - L + 1 > 2) ? (L + R >> 1) : R; if (i & 1) s -= M; else s += M; if (ask(s)) {ans = M; R = M - 1;} else {L = M + 1;} } cout << "= " << ans << endl; } return 0; }

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

Colors.cpp: In function 'int main()':
Colors.cpp:27:32: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |    ll M = (R - L + 1 > 2) ? (L + R >> 1) : R;
      |                              ~~^~~
Colors.cpp:38:32: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |    ll M = (R - L + 1 > 2) ? (L + R >> 1) : R;
      |                              ~~^~~
#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...