Submission #1059157

#TimeUsernameProblemLanguageResultExecution timeMemory
10591571neXylophone (JOI18_xylophone)C++17
0 / 100
0 ms344 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int N) { int i = 1; while(query(i,N) == N - 1){ ++i; } answer(i - 1,1); int pos = i - 1; int mn = 1,vv = 1; vector<int>ans(N + 1,-1); ans[i - 1] = 1; //2 3 1 auto maxquery = [&](int u,int v){ }; auto minquery = [&](int u,int v){ }; //3 2 4 1 vector<int>got(N + 1,0); for (int j = i - 2;j>=1;){ if (mn){ int v = query(j,pos); if (got[v]){ mn = 0; vv = ans[j + 1]; pos = j + 1; for(int k = 0;k<=N;++k){ got[k] = 0; } } else{ got[v] = 1; ans[j] = v + vv; answer(j,v + vv); --j; } } else{ int v = query(j,pos); if (got[v]){ mn = 1; vv = ans[j + 1]; pos = j + 1; for (int k = 0;k<=N;++k){ got[k] = 0; } } else{ got[v] = 1; ans[j] = vv - v; answer(j,vv - v); --j; } } } mn = 1; pos = i - 1; for (int j = 0;j<=N;++j)got[j] = 0; vv = 1; int en = -1; for (int j = i;;++j){ if (mn){ int v = query(pos,j); if (got[v]){ mn = 0; vv = ans[j - 1]; pos = j - 1; for(int k = 0;k<=N;++k){ got[k] = 0; } } else{ got[v] = 1; answer(j,v + vv); ans[j] =v + vv; if (v + vv == N){ en = j; break; } ++j; } } else{ int v = query(pos,j); if (got[v]){ mn = 1; vv = ans[j - 1]; pos = j - 1; for (int k = 0;k<=N;++k){ got[k] = 0; } } else{ got[v] = 1; ans[j] = vv - v; answer(j,vv - v); ++j; } } } mn = 0; vv = N; pos = en; for (int j = 0;j<=N;++j){ got[j] = 0; } for (int j = en + 1;j<=N;){ if (mn){ int v = query(pos,j); if (got[v]){ mn = 0; vv = ans[j - 1]; pos = j - 1; for(int k = 0;k<=N;++k){ got[k] = 0; } } else{ got[v] = 1; ans[j] = v + vv; answer(j,v + vv); ++j; } } else{ int v = query(pos,j); if (got[v]){ mn = 1; vv = ans[j - 1]; pos = j - 1; for (int k = 0;k<=N;++k){ got[k] = 0; } } else{ got[v] = 1; ans[j] = vv - v; answer(j,vv - v); ++j; } } } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:17:10: warning: variable 'maxquery' set but not used [-Wunused-but-set-variable]
   17 |     auto maxquery = [&](int u,int v){
      |          ^~~~~~~~
xylophone.cpp:20:10: warning: variable 'minquery' set but not used [-Wunused-but-set-variable]
   20 |     auto minquery = [&](int u,int v){
      |          ^~~~~~~~
xylophone.cpp: At global scope:
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...