Submission #730002

#TimeUsernameProblemLanguageResultExecution timeMemory
730002nguyentunglamXylophone (JOI18_xylophone)C++17
100 / 100
113 ms572 KiB
#include<bits/stdc++.h> using namespace std; #include "xylophone.h" static int A[5000]; const int N = 1e5 + 10; int a[N], b[N], c[N], d[N], cnt[N]; int n; void Find(int e[]) { for(int i = 3; i <= n; i++) { e[i] = e[i - 1] + a[i]; if (max({e[i - 2], e[i - 1], e[i]}) - min({e[i - 2], e[i - 1], e[i]}) != b[i]) e[i] = e[i - 1] - a[i]; } int p = 0; for(int i = 1; i <= n; i++) p = max(p, 1 - e[i]); for(int i = 1; i <= n; i++) e[i] += p; } void solve(int _n) { n = _n; for(int i = 2; i <= n; i++) a[i] = query(i - 1, i); for(int i = 3; i <= n; i++) b[i] = query(i - 2, i); c[2] = a[2]; d[2] = -a[2]; Find(c); Find(d); int mx = 0, mn = 0; bool ok = 1; for(int i = 1; i <= n; i++) { if (c[i] == 1) mn = i; if (c[i] == n) mx = i; if (1 <= c[i] && c[i] <= n) cnt[c[i]]++; else ok = 0; if (cnt[c[i]] > 1) ok = 0; } if (ok && mn < mx && query(mn, mx) == n - 1) for(int i = 1; i <= n; i++) answer(i, c[i]); else for(int i = 1; i <= n; i++) answer(i, d[i]); }

Compilation message (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...