#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
vector<int> ans;
std::vector<int> SortDisks(int N) {
ans.resize(N);
vector<int> v;
for(int i = 0; i < N; i++) v.push_back(i);
int left = N;
int sum = 0;
int X = PutDisks(v);
for(int i = 0; left > 1; i++) {
int t = v[left - 1];
for(int j = left - 1; j > 0; j--) v[j] = v[j - 1];
v[0] = t;
int Y = PutDisks(v);
if(Y != X - 1) {
t = v[0];
ans[t] = Y - N + 1;
sum += ans[t];
int lb = lower_bound(v.begin() + left, v.end(), t, [&](const int a, const int b) { return ans[a] < ans[b]; } ) - v.begin();
for(int j = 0; j < lb - 1; j++) v[j] = v[j + 1];
v[lb - 1] = t;
left--;
}
}
ans[v[0]] = N * (N + 1) / 2 - sum;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
320 KB |
Output is correct |
2 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
320 KB |
Output is correct |
2 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
320 KB |
Output is correct |
2 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |