Submission #996050

#TimeUsernameProblemLanguageResultExecution timeMemory
996050fimhXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; #define fi first #define se second const ll N = 5e3 + 5; const ll blocksz = 320; const ll mod = 1e9 + 7; const ll inf = 1e18; ll rep, n; ll a[N]; bool f[N]; bool check(){ for (int i = 1; i <= n; ++i){ if (a[i] == n) return 0; if (a[i] == 1) break; } if (*min_element(a + 1, a + n + 1) != 1) return 0; if (*max_element(a + 1, a + n + 1) != n) return 0; for (int i = 1; i <= n; ++i) f[i] = 0; for (int i = 1; i <= n; ++i) f[a[i]] = 1; for (int i = 1; i <= n; ++i) if (!f[i]) return 0; return 1; } // ll query(ll l, ll r){ // cout << l << " " << r << endl; // cin >> rep; // return rep; // } // void answer(ll i, ll x){ // a[i] = x; // } void solve(){ cin >> n; ll d = query(1, 2); for (int i = 1; i < n; ++i){ a[1] = i; if (a[1] - d >= 1){ a[2] = a[1] - d; for (int i = 3; i <= n; ++i){ ll t1 = query(i - 1, i); ll t2 = query(i - 2, i); if (a[i - 2] > a[i - 1]){ if (t2 >= t1) a[i] = a[i - 1] + t1; else a[i] = a[i - 1] - t1; }else{ if (t2 < t1) a[i] = a[i - 1] + t1; else a[i] = a[i - 1] - t1; } } // for (int i = 1; i <= n; ++i) cout << a[i] << " "; if (check()){ for (int i = 1; i <= n; ++i){ answer(i, a[i]); } return; } } if (a[1] + d <= n){ a[2] = a[1] + d; for (int i = 3; i <= n; ++i){ ll t1 = query(i - 1, i); ll t2 = query(i - 2, i); if (a[i - 2] > a[i - 1]){ if (t2 >= t1) a[i] = a[i - 1] + t1; else a[i] = a[i - 1] - t1; }else{ if (t2 < t1) a[i] = a[i - 1] + t1; else a[i] = a[i - 1] - t1; } } // for (int i = 1; i <= n; ++i) cout << a[i] << " "; if (check()){ for (int i = 1; i <= n; ++i){ answer(i, a[i]); } return; } } } } signed main(){ // ios_base::sync_with_stdio(0); // cin.tie(0); cout.tie(0); ll TC = 1; // cin >> TC; while (TC--){ solve(); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve()':
xylophone.cpp:44:13: error: 'query' was not declared in this scope
   44 |      ll d = query(1, 2);
      |             ^~~~~
xylophone.cpp:63:26: error: 'answer' was not declared in this scope
   63 |                          answer(i, a[i]);
      |                          ^~~~~~
xylophone.cpp:84:26: error: 'answer' was not declared in this scope
   84 |                          answer(i, a[i]);
      |                          ^~~~~~