제출 #1190519

#제출 시각아이디문제언어결과실행 시간메모리
1190519Panda50OXylophone (JOI18_xylophone)C++20
100 / 100
27 ms476 KiB
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; int B[5001]; int d1[5001], d2[5001]; void solve(int N) { for(int i = 1; i <= N-1; ++i) { d1[i] = query(i, i+1); } for(int i = 1; i <= N-2; ++i) { d2[i] = query(i, i+2); } B[1] = 0; B[2] = B[1] + d1[1]; for(int i = 3; i <= N; ++i) { B[i] = B[i-1] + d1[i-1]; if(max({abs(B[i]-B[i-1]), abs(B[i]-B[i-2]), abs(B[i-1]-B[i-2])}) != d2[i-2]) { B[i] = B[i-1] - d1[i-1]; } } int mn = 1e9; for(int i = 1; i <= N; ++i) { mn = min(mn, B[i]); } for(int i = 1; i <= N; ++i) { B[i] += (1-mn); } for(int i = 1; i <= N; ++i) { if(B[i] == 1) break; else if(B[i] == N) { for(int j = 1; j <= N; ++j) { B[j] = N - B[j] + 1; } break; } } for(int i = 1; i <= N; i++) { answer(i, B[i]); } } /* 5 1 5 3 4 2 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...