Submission #1107715

#TimeUsernameProblemLanguageResultExecution timeMemory
1107715KK_1729Xylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // #define int long long #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define pb push_back #define all(a) a.begin(), a.end() #define endl "\n" void printVector(vector<int> a){ for (auto x: a) cout << x << " "; cout << endl; } void solve(int n){ vector<int> diff(n+1); FOR(i,1,n){ diff[i] = query(i, i+1); } vector<int> type(n+1, -1); type[1] = 1; FOR(i,1,n-1){ int e = query(i, i+2); if (e == diff[i]+diff[i+1]){ type[i+1] = type[i]; }else{ type[i+1] = type[i]^1; } } vector<int> a(n+1); FOR(i,1,n){ if (type[i] == 1){ a[i+1] = a[i]+diff[i]; }else{ a[i+1] = a[i]-diff[i]; } } int mini = 1e9; int maxi = 0; int minind = 0; int maxind = 0; FOR(i,1,n+1){ if (a[i] < mini){ minind = i; } if (a[i] > maxi){ maxind = i; } mini = min(mini, a[i]); maxi = max(maxi, a[i]); } // printVector(a); if (maxi - mini == n-1 && maxind > minind){ FOR(i,1,n+1){ answer(i, a[i]-(mini-1)); } return; } a.clear();a.resize(n+1); FOR(i,1,n){ if (type[i] == 1){ a[i+1] = a[i]-diff[i]; }else{ a[i+1] = a[i]+diff[i]; } } mini = 1e9; maxi = 0; FOR(i,1,n+1){ mini = min(mini, a[i]);maxi = max(maxi, a[i]); } FOR(i,1,n+1){ answer(i, a[i]-(mini-1)); } return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:17:19: error: 'query' was not declared in this scope
   17 |         diff[i] = query(i, i+1);
      |                   ^~~~~
xylophone.cpp:23:17: error: 'query' was not declared in this scope
   23 |         int e = query(i, i+2);
      |                 ^~~~~
xylophone.cpp:57:13: error: 'answer' was not declared in this scope
   57 |             answer(i, a[i]-(mini-1));
      |             ^~~~~~
xylophone.cpp:76:9: error: 'answer' was not declared in this scope
   76 |         answer(i, a[i]-(mini-1));
      |         ^~~~~~