# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1059169 |
2024-08-14T18:02:17 Z |
1ne |
Xylophone (JOI18_xylophone) |
C++17 |
|
1 ms |
344 KB |
#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;;){
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
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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [4] |
4 |
Halted |
0 ms |
0 KB |
- |