제출 #412167

#제출 시각아이디문제언어결과실행 시간메모리
412167nichkeXylophone (JOI18_xylophone)C++14
0 / 100
2 ms200 KiB
#include <bits/stdc++.h> using namespace std; void answer(int a, int b); int query(int a, int b); void solve(int n) { int cur = query(1, n); int mn = 1; vector<int> ans(n + 1); for (int i = 2; i <= n; i++) { int tmp = query(i, n); if (tmp != cur) { mn = i - 1; break; } cur = tmp; } ans[mn] = 1; cur = 0; for (int i = mn - 1; i >= 1; i--) { int tmp = query(i, mn); if (tmp != cur) { ans[i] = tmp + 1; } else { ans[i] = ans[i + 1] - query(i, i + 1); } cur = tmp; } cur = 0; for (int i = mn + 1; i <= n; i++) { int tmp = query(mn, i); if (tmp != cur) { ans[i] = tmp + 1; } else { ans[i] = ans[i - 1] - query(i - 1, i); } cur = tmp; } for (int i = 1; i <= n; i++) { answer(i, ans[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...