// N <= 50
#include <algorithm>
#include <vector>
#include "grid.h"
std::vector<int> SortDisks(int N) {
std::vector<int> tmp(N);
std::vector<int> ans(N);
for (int i = 0; i < N; ++i) tmp[i] = i;
for (int t = N - 1; t >= 1; --t) {
int maxlen = -1;
int maxt = -1;
for (int i = 0; i <= t; ++i) {
std::swap(tmp[0], tmp[i]);
const int len = PutDisks(tmp);
std::swap(tmp[0], tmp[i]);
if (len > maxlen) {
maxlen = len;
maxt = i;
}
}
std::swap(tmp[t], tmp[maxt]);
}
for (int i = 0; i < N; ++i) ans[tmp[i]] = i + 1;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
8 |
Correct |
7 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
8 |
Correct |
7 ms |
256 KB |
Output is correct |
9 |
Incorrect |
7 ms |
256 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
8 |
Correct |
7 ms |
256 KB |
Output is correct |
9 |
Incorrect |
7 ms |
256 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |