제출 #788785

#제출 시각아이디문제언어결과실행 시간메모리
788785tch1cherinXylophone (JOI18_xylophone)C++17
0 / 100
1 ms208 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; void solve(int N) { vector<int> d(N - 1); for (int i = 0; i < N - 1; i++) { d[i] = query(i + 1, i + 2); } for (int i = 1; i < N - 1; i++) { if (query(i, i + 2) != abs(d[i - 1]) + d[i]) { d[i] *= d[i - 1] < 0 ? 1 : -1; } } for (int r = 0; r < 2; r++) { vector<int> p = d; p.insert(p.begin(), 0); partial_sum(p.begin(), p.end(), p.begin()); int Min = *min_element(p.begin(), p.end()); int good = 0; for (int &v : p) { v -= Min - 1; if (v == 1 && good == 0) { good++; } if (v == N && good == 1) { good++; } } if (good == 2) { for (int i = 0; i < N; i++) { answer(1 + i, p[i]); } } for (int i = 0; i < N - 1; i++) { d[i] *= -1; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...