제출 #552554

#제출 시각아이디문제언어결과실행 시간메모리
552554RaresFelixXylophone (JOI18_xylophone)C++17
100 / 100
105 ms592 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; int n; void solve(int N) { n = N; if(n == 2) { answer(1, 1), answer(2, 2); return; } vector<int> R1, R2, Tip; for(int i = 1; i < n; ++i) R1.push_back(query(i, i + 1)); for(int i = 1; i < n - 1; ++i) R2.push_back(query(i, i + 2)); Tip.push_back(1); for(int i = 1; i < n - 1; ++i) { if(R2[i-1] != R1[i-1] + R1[i]) Tip.push_back(-Tip.back()); else Tip.push_back(Tip.back()); } vector<int> Dif; for(int i = 1; i < n; ++i) Dif.push_back(R1[i-1] * Tip[i-1]); vector<int> R; R.push_back(0); int mi = 0; for(int i = 0; i < n - 1; ++i){ R.push_back(R.back() + Dif[i]); mi = min(mi, R.back()); } for(int i = 0; i < n; ++i) R[i] -= mi - 1; int ok = 1; for(int i = 0; i < n; ++i) { if(R[i] == 1) break; if(R[i] == n) { ok = 0; break; } } if(!ok) for(auto &it : R) it = n - it + 1; for(int i = 0; i < n; ++i) answer(i + 1, R[i]); }

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

xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
    4 | static int A[5000];
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...