#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> SortDisks(int n){
vector<int> v(n);
vector<int> ans(n);
iota(v.begin(), v.end(), 0);
int p = PutDisks(v);
int found = 0;
while(found < n){
auto w = v;
rotate(w.begin(), w.end() - found - 1, w.end() - found);
int q = PutDisks(w);
if(q == n){
for(int i=0; i+found<n; i++){
ans[w[i]] = i + 1;
}
break;
}
if(q >= p){
ans[w[0]] = q - n + 1;
found++;
sort(v.end() - found, v.end(), [&](const int &a, const int &b){
return ans[a] < ans[b];
});
}
else{
p = q;
v = w;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
252 KB |
Output is correct |
14 |
Correct |
3 ms |
248 KB |
Output is correct |
15 |
Correct |
3 ms |
248 KB |
Output is correct |
16 |
Correct |
3 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
252 KB |
Output is correct |
14 |
Correct |
3 ms |
248 KB |
Output is correct |
15 |
Correct |
3 ms |
248 KB |
Output is correct |
16 |
Correct |
3 ms |
248 KB |
Output is correct |
17 |
Correct |
4 ms |
248 KB |
Output is correct |
18 |
Correct |
11 ms |
248 KB |
Output is correct |
19 |
Correct |
14 ms |
248 KB |
Output is correct |
20 |
Correct |
17 ms |
380 KB |
Output is correct |
21 |
Correct |
13 ms |
376 KB |
Output is correct |
22 |
Correct |
18 ms |
504 KB |
Output is correct |
23 |
Correct |
17 ms |
248 KB |
Output is correct |
24 |
Correct |
17 ms |
248 KB |
Output is correct |
25 |
Correct |
18 ms |
376 KB |
Output is correct |
26 |
Correct |
18 ms |
376 KB |
Output is correct |