# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
151605 |
2019-09-03T17:21:26 Z |
ainta |
On the Grid (FXCUP4_grid) |
C++17 |
|
16 ms |
380 KB |
#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) {
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;
prev = PutDisks(w);
}
}
vector<int>Ans(n);
for (i = 0; i < n; i++)Ans[i] = Len[i];
return Ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 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 |
4 ms |
248 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
252 KB |
Output is correct |
14 |
Correct |
3 ms |
312 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
252 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 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 |
4 ms |
248 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
252 KB |
Output is correct |
14 |
Correct |
3 ms |
312 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
296 KB |
Output is correct |
17 |
Correct |
6 ms |
248 KB |
Output is correct |
18 |
Incorrect |
16 ms |
248 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |