#include "grid.h"
#include <bits/stdc++.h>
using namespace std;
const int TRIALS = 5;
bool check(int N, int target_stick, int target_level, vector<int> undetermined, vector<int>& determined) {
for (int t = 0; t < TRIALS; t++) {
vector<int> p(1, target_stick);
random_shuffle(undetermined.begin(), undetermined.end());
for (int elm : undetermined) {
if (elm != target_stick) {
p.push_back(elm);
}
}
for (int elm : determined) {
p.push_back(elm);
}
int verdict = PutDisks(p);
if (verdict < target_level + N - 1) {
return false;
}
}
return true;
}
vector<int> L;
bool cmp(int u, int v) {
return L[u] < L[v];
}
vector<int> SortDisks(int N) {
L = vector<int>(N, 0);
srand(882);
for (int i = N; i >= 1; i--) {
vector<int> determined, undetermined;
for (int i = 0; i < N; i++) {
if (L[i]) {
determined.push_back(i);
} else {
undetermined.push_back(i);
}
}
sort(determined.begin(), determined.end(), cmp);
random_shuffle(undetermined.begin(), undetermined.end());
for (int elm : undetermined) {
if (check(N, elm, i, undetermined, determined)) {
L[elm] = i;
break;
}
}
}
return L;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 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 |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
256 KB |
Output is correct |
9 |
Incorrect |
14 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
256 KB |
Output is correct |
9 |
Incorrect |
14 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |