#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);
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;
}
while(true){
int x=dq.back();
dq.pop_back();
dq.push_front(x);
int cur=ask();
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;
}
}
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 |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 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 |
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 |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 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 |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
340 KB |
Output is correct |
19 |
Correct |
13 ms |
368 KB |
Output is correct |
20 |
Correct |
15 ms |
336 KB |
Output is correct |
21 |
Correct |
8 ms |
340 KB |
Output is correct |
22 |
Correct |
16 ms |
340 KB |
Output is correct |
23 |
Correct |
16 ms |
340 KB |
Output is correct |
24 |
Correct |
16 ms |
328 KB |
Output is correct |
25 |
Correct |
17 ms |
340 KB |
Output is correct |
26 |
Correct |
16 ms |
376 KB |
Output is correct |