제출 #763253

#제출 시각아이디문제언어결과실행 시간메모리
763253CESxRhinoXylophone (JOI18_xylophone)C++14
0 / 100
2 ms208 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int re[200005]; int a[200005]; int b[200005]; void solve(int N) { for(int i = 1;i <= N - 1;i++) { a[i] = query(i,i + 1); } for(int i = 1;i <= N - 2;i++) { b[i] = query(i,i + 2); } re[1] = 1; for(int i = 1;i <= N - 2;i++) { if(a[i] + a[i + 1] == b[i]) { re[i + 1] = re[i]; } else { re[i + 1] = -re[i]; } } a[N] = 0; int Min = 0; for(int i = N - 1;i >= 1;i--) { a[i] = a[i + 1] - re[i] * a[i]; Min = min(Min,a[i]); } for(int i = 1;i <= N;i++) { a[i] = a[i] - Min + 1; } for(int i = 1;i <= N;i++) { if(a[i] == 1) { break; } if(a[i] == N) { for(int j = 1;j <= N;j++) { a[j] = N + 1 - a[j]; } } } for(int i = 1;i <= N;i++) { answer(i,a[i]); } cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...