Submission #918518

#TimeUsernameProblemLanguageResultExecution timeMemory
918518viwlesxqXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() #define size(x) (int)x.size() template<class S, class T> bool chmin(S &a, const T &b) { return a > b && (a = b) == b; } template<class S, class T> bool chmax(S &a, const T &b) { return a < b && (a = b) == b; } const int inf = 1e9 + 7; const int INF = 1e18 + 7; const int mod = 1e9 + 7; void solve(int n) { vector<int> a(n); int min = 0, max = n - 1; for (int i = 1; i < n; ++i) { if (query(i + 1, n) != n - 1) break; min = i; } for (int i = n - 2; i >= 0; --i) { if (query(1, i + 1) != n - 1) break; max = i; } a[min] = 1, a[max] = n; int last = min, val = 0; bool increasing = true; for (int i = min - 1; i >= 0; --i) { int diff = query(i + 1, last + 1); if (diff == val) { last = i + 1; diff = query(i + 1, last + 1); increasing ^= true; } a[i] = a[last] + (increasing ? diff : -diff); val = diff; } last = min, val = 0; increasing = true; for (int i = min + 1; i < max; ++i) { int diff = query(last + 1, i + 1); if (diff == val) { last = i + 1; diff = query(last + 1, i + 1); increasing ^= true; } a[i] = a[last] + (increasing ? diff : -diff); val = diff; } last = max, val = 0; increasing = false; for (int i = max + 1; i < n; ++i) { int diff = query(last + 1, i + 1); if (diff == val) { last = i - 1; diff = query(last + 1, i + 1); increasing ^= true; } a[i] = a[last] + (increasing ? diff : -diff); val = diff; } for (int i = 0; i < n; ++i) { answer(i + 1, a[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:23:13: error: 'query' was not declared in this scope
   23 |         if (query(i + 1, n) != n - 1) break;
      |             ^~~~~
xylophone.cpp:27:13: error: 'query' was not declared in this scope
   27 |         if (query(1, i + 1) != n - 1) break;
      |             ^~~~~
xylophone.cpp:34:20: error: 'query' was not declared in this scope
   34 |         int diff = query(i + 1, last + 1);
      |                    ^~~~~
xylophone.cpp:46:20: error: 'query' was not declared in this scope
   46 |         int diff = query(last + 1, i + 1);
      |                    ^~~~~
xylophone.cpp:58:20: error: 'query' was not declared in this scope
   58 |         int diff = query(last + 1, i + 1);
      |                    ^~~~~
xylophone.cpp:68:9: error: 'answer' was not declared in this scope
   68 |         answer(i + 1, a[i]);
      |         ^~~~~~