#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int pos[1005]; ///position of size i
int ans[1005];
vector<int> confirmed;
int wrap(vector<int> v){
for (int x = confirmed.size()-1; x>=0; x--){
v.push_back(confirmed[x]);
}
vector<int> newv;
for (auto x : v){
newv.push_back(x-1);
}
int res = PutDisks(newv);
return res-confirmed.size();
}
vector<int> SortDisks(int N) {
n = N;
for (int x = N; x>0; x--){
vector<int> qu;
vector<int> rem;
for (int y = 1; y<=N; y++){
if (ans[y]!=0) continue;
qu.push_back(y);
rem.push_back(y);
}
int res = wrap(qu);
int num = res - x;
qu.clear();
for (int y = x-num; y<=x; y++){
qu.push_back(rem[y-1]);
}
for (int y = 1; y<x-num; y++){
qu.push_back(rem[y-1]);
}
//printf("num = %d\n",num);
res = wrap(qu);
res -= (x-num-1);
res -= x;
pos[x] = rem[x-res-1];
ans[rem[x-res-1]] = x;
confirmed.push_back(rem[x-res-1]);
//printf("confirmed %d\n",rem[x-res-1]);
}
vector<int> ans2;
for (int x = 1; x<=n; x++){
ans2.push_back(ans[x]);
}
return ans2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |