#include "grid.h"
#include<algorithm>
#include<vector>
using namespace std;
#define pii pair<int,int>
vector<int>w, TP;
int Len[1010];
vector<int> SortDisks(int n) {
int i;
for (i = 0; i < n; i++) {
w.push_back(i);
Len[i] = -1;
}
int prev = PutDisks(w);
while (1) {
for (i = 0; i < n; i++) {
if (Len[w[i]] != -1)break;
}
int L = i;
if (L == 0)break;
TP = w;
int z = w[L-1];
for (i = L-1; i > 0; i--)w[i] = w[i - 1];
w[0] = z;
int cur = PutDisks(w);
if (cur == prev - 1) {
prev = cur;
continue;
}
else {
Len[w[0]] = cur - n + 1;
w = TP;
vector<pii>V;
for (i = L - 1; i < n; i++) {
V.push_back({ Len[w[i]],w[i] });
}
sort(V.begin(), V.end());
int pv = L - 1;
for (auto &t : V)w[pv++] = t.second;
}
}
vector<int>Ans(n);
for (i = 0; i < n; i++)Ans[i] = Len[i];
return Ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |