제출 #714235

#제출 시각아이디문제언어결과실행 시간메모리
714235four_specksXylophone (JOI18_xylophone)C++17
100 / 100
117 ms592 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int N) { vector mem(N, vector<int>(3, -1)); auto qry = [&](int k, int d) { if (mem[k][d] == -1) mem[k][d] = query(k + 1, k + d + 1); return mem[k][d]; }; vector<bool> dir(N - 1); vector<int> diff(N - 1); diff[0] = qry(0, 1); for (int i = 0; i < N - 2; i++) { int x = qry(i, 1), y = qry(i + 1, 1), z = qry(i, 2); dir[i + 1] = dir[i] ^ (x + y != z); diff[i + 1] = y; } vector<int> a(N); for (int i = 0; i < N - 1; i++) a[i + 1] = a[i] + (dir[i] ? diff[i] : -diff[i]); if (max_element(a.begin(), a.end()) < min_element(a.begin(), a.end())) { for (int i = 0; i < N; i++) a[i] = -a[i]; } int sub = *min_element(a.begin(), a.end()); for (int i = 0; i < N; i++) a[i] = a[i] - sub; for (int i = 0; i < N; i++) answer(i + 1, a[i] + 1); }

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

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