#include "grid.h"
#include <algorithm>
using namespace std;
pair<int, int> a[1001];
std::vector<int> SortDisks(int N) {
vector<int> t(N);
int i, j, k, l, m = N;
for (i = 0; i < N; i++) t[i] = i;
for (i = 0; i < N; i++) {
a[i].first = -N;
a[i].second = i;
}
for (i = 0; i < 2000; i++) {
for (j = 0; j < N; j++) t[j] = a[j].second;
k = PutDisks(t);
l = 0;
for (j = 0; j < N; j++) {
if (a[j].first <= N - j - k - 1) l++;
a[j].first = max(a[j].first, N - j - k - 1);
}
if (l == 1) {
for (j = 0; j < m; j++) if (a[j].first == N - j - k - 1) {
swap(a[j], a[--m]);
break;
}
}
sort(a, a + m);
}
for (j = 0; j < N; j++) t[a[j].second] = -a[j].first;
return t;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 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 |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 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 |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
8 ms |
256 KB |
Output is correct |
10 |
Correct |
12 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
384 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
12 ms |
384 KB |
Output is correct |
15 |
Correct |
12 ms |
256 KB |
Output is correct |
16 |
Correct |
12 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 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 |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
8 ms |
256 KB |
Output is correct |
10 |
Correct |
12 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
384 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
12 ms |
384 KB |
Output is correct |
15 |
Correct |
12 ms |
256 KB |
Output is correct |
16 |
Correct |
12 ms |
384 KB |
Output is correct |
17 |
Correct |
18 ms |
384 KB |
Output is correct |
18 |
Incorrect |
56 ms |
384 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |