Submission #98849

#TimeUsernameProblemLanguageResultExecution timeMemory
98849janchomathXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
//#include "grader.cpp" #include<bits/stdc++.h> #define ll long long using namespace std; bool fix[200005]; ll ans[200005],ind; void solve(int n) { ll l = 2,r = n,mid = 0; while(l <= r){ mid = (l + r) / 2; ll curans = query(1,mid); // cout << 1 << " " << mid << " " << curans << endl; if(curans != n - 1){ l = mid + 1; } else { ind = mid; r = mid - 1; } } ans[ind] = n; fix[n] = 1; if(ind != n){ ans[ind + 1] = n - query(ind,ind + 1); } for(int i=ind+1; i<=n; i++){ fix[ans[i]] = 1; if(i == n){ break; } ll k1 = query(i,i + 1); if(ans[i] + k1 >= n || fix[ans[i] + k1]){ ans[i + 1] = ans[i] - k1; continue; } if(ans[i] - k1 <= 0 || fix[ans[i] - k1]){ ans[i + 1] = ans[i] + k1; continue; } ll k2 = query(i - 1,i + 1); if(ans[i - 1] < ans[i]){ if(k2 == k1 + ans[i] - ans[i - 1]){ ans[i + 1] = ans[i] + k1; } else { ans[i + 1] = ans[i] - k1; } } else { if(k2 == k1 + ans[i - 1] - ans[i]){ ans[i + 1] = ans[i] - k1; } else { ans[i + 1] = ans[i] + k1; } } } if(ind > 1){ ans[ind - 1] = n - query(ind-1,ind); } for(int i=ind - 1; i>=1; i--){ fix[ans[i]] = 1; // cout << i << " " << ans[i] << endl; if(i == 1){ break; } ll k1 = query(i - 1,i); if(ans[i] + k1 >= n || fix[ans[i] + k1]){ ans[i - 1] = ans[i] - k1; continue; } if(ans[i] - k1 <= 0 || (fix[ans[i] - k1] && ans[i] - k1 >= 0)){ ans[i - 1] = ans[i] + k1; continue; } // cout << "ET\n"; ll k2 = query(i - 1,i + 1); if(ans[i + 1] < ans[i]){ if(k2 == k1 + ans[i] - ans[i + 1]){ ans[i - 1] = ans[i] + k1; } else { ans[i - 1] = ans[i] - k1; } } else { if(k2 == k1 + ans[i + 1] - ans[i]){ ans[i - 1] = ans[i] - k1; } else { ans[i - 1] = ans[i] + k1; } } } for(int i=1; i<=n; i++){ // cout << ans[i] << endl; answer(i,ans[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:12:15: error: 'query' was not declared in this scope
   ll curans = query(1,mid);
               ^~~~~
xylophone.cpp:26:22: error: 'query' was not declared in this scope
   ans[ind + 1] = n - query(ind,ind + 1);
                      ^~~~~
xylophone.cpp:34:11: error: 'query' was not declared in this scope
   ll k1 = query(i,i + 1);
           ^~~~~
xylophone.cpp:64:22: error: 'query' was not declared in this scope
   ans[ind - 1] = n - query(ind-1,ind);
                      ^~~~~
xylophone.cpp:72:11: error: 'query' was not declared in this scope
   ll k1 = query(i - 1,i);
           ^~~~~
xylophone.cpp:104:3: error: 'answer' was not declared in this scope
   answer(i,ans[i]);
   ^~~~~~
xylophone.cpp:104:3: note: suggested alternative: 'ans'
   answer(i,ans[i]);
   ^~~~~~
   ans