#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
bool use[1005];
deque<int> dq;
set<pair<int,int>> done;
int ask(){
vector<int> v;
for(int i:dq)v.push_back(i);
for(auto it:done)v.push_back(it.second);
//printf("ask: ");
//for(int i:v)printf("%d ",i);
//printf("\n");
return PutDisks(v);
}
vector<int> SortDisks(int N){
for(int i=0;i<N;++i)dq.push_back(i);
vector<int> ans(N);
while(!dq.empty()){
if(dq.size()==1){
for(int i=1;i<=N;++i){
if(!use[i])ans[dq[0]]=i;
}
break;
}
int pv=ask();
while(true){
int x=dq.back();
dq.pop_back();
dq.push_front(x);
int cur=ask();
if(cur<pv&&dq.size()==2){
swap(cur,pv);
swap(dq[0],dq[1]);
}
if(cur>=pv){
int res=cur-N+1;
use[res]=true;
ans[dq.front()]=res;
done.insert({res,dq.front()});
dq.pop_front();
break;
}
pv=cur;
}
}
//printf("ans: ");
//for(int i:ans)printf("%d ",i);
//printf("\n");
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
308 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
308 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Incorrect |
12 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |