제출 #680559

#제출 시각아이디문제언어결과실행 시간메모리
680559nutellaXylophone (JOI18_xylophone)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int N) { vector<bool> was(N + 1); int lo = -1, hi = N - 1; while (lo + 1 < hi) { int mid = lo + hi >> 1; if (query(1, mid + 1) == N - 1) { hi = mid; } else { lo = mid; } } answer(hi + 1, N); was[N] = true; int mn = N, pos = hi; for (int i = hi - 1; i >= 0; --i) { int diff = query(i + 1, pos + 1); int a; if (diff + mn > N || was[diff + mn]) { a = mn - diff; } else if (mn - diff <= 0 || was[mn - diff]) { a = mn + diff; } else if (query(i + 1, hi + 1) == N - mn) { a = mn + diff; } else { a = mn - diff; } answer(i + 1, a); was[a] = true; if (mn > a) { mn = a; pos = i; } } mn = N, pos = hi; for (int i = hi + 1; i < N; ++i) { int diff = query(pos + 1, i + 1); int a; if (diff + mn > N || was[diff + mn]) { a = mn - diff; } else if (mn - diff <= 0 || was[mn - diff]) { a = mn + diff; } else if (query(hi + 1, i + 1) == N - mn) { a = mn + diff; } else { a = mn - diff; } answer(i + 1, a); was[a] = true; if (mn > a) { mn = a; pos = i; } } }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:11:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   11 |         int mid = lo + hi >> 1;
      |                   ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...