#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> SortDisks(int N) {
vector<int> ans(N), ord(N), check(N, -1);
for (int i = 0; i < N; i++) ord[i] = i;
int prev = PutDisks(ord), curr;
while (!ord.empty()){
int firstin = ord.back();
for (int i = ord.size() - 1; i > 0; i--) ord[i] = ord[i - 1];
ord[0] = firstin;
vector<int> test(N);
int ind = 0;
for (int i = 0; i < N; i++){
if (check[i] != -1) test[i] = check[i];
else test[i] = ord[ind++];
}
curr = PutDisks(test);
if (curr >= prev){
ans[firstin] = curr - N + 1;
check[ans[firstin] - 1] = firstin;
ord.erase(ord.begin());
}
else prev = curr;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
292 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
292 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
296 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
292 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
296 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
204 KB |
Output is correct |
18 |
Correct |
8 ms |
204 KB |
Output is correct |
19 |
Correct |
9 ms |
320 KB |
Output is correct |
20 |
Correct |
11 ms |
204 KB |
Output is correct |
21 |
Correct |
5 ms |
204 KB |
Output is correct |
22 |
Correct |
12 ms |
324 KB |
Output is correct |
23 |
Correct |
10 ms |
296 KB |
Output is correct |
24 |
Correct |
10 ms |
296 KB |
Output is correct |
25 |
Correct |
10 ms |
320 KB |
Output is correct |
26 |
Correct |
11 ms |
320 KB |
Output is correct |