#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
bool use[1005];
deque<int> dq;
//vector<int> done;
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);
int pv=ask();
while(!dq.empty()){
if(dq.size()==1){
for(int i=1;i<=N;++i){
if(!use[i])ans[dq[0]]=i;
}
break;
}
//if(toask)pv=ask();
while(true){
int x=dq.back();
dq.pop_back();
dq.push_front(x);
int cur=ask();
//printf("res: %d\n",cur);
/*
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;
//printf("fix: %d %d\n",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 |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
224 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
232 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 |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
224 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
232 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
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 |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
224 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
232 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
340 KB |
Output is correct |
19 |
Correct |
12 ms |
400 KB |
Output is correct |
20 |
Correct |
16 ms |
372 KB |
Output is correct |
21 |
Correct |
8 ms |
304 KB |
Output is correct |
22 |
Correct |
14 ms |
340 KB |
Output is correct |
23 |
Correct |
16 ms |
340 KB |
Output is correct |
24 |
Correct |
15 ms |
356 KB |
Output is correct |
25 |
Correct |
14 ms |
312 KB |
Output is correct |
26 |
Correct |
15 ms |
384 KB |
Output is correct |