#include <bits/stdc++.h>
#include "grid.h"
using namespace std;
int ct[1005][1005];
int Q[1005];
int done[1005];
int ans[1005];
int mn[1005];
int query(int N){
vector<int> res;
for (int i = 0; i < N; i++) res.push_back(Q[i]);
return PutDisks(res);
}
vector<int> SortDisks(int N) {
for (int i = 0; i < N; i++){
mn[i] = N;
}
for (int T = N; T >= 1; T--){
//printf("solving %d now\n",T);
int id = 0;
for (int i = 0; i < N; i++) {
if (done[i]) continue;
Q[id++] = i;
}
while (true){
random_shuffle(Q,Q+T);
int X = query(N);
X -= N;
for (int j = 0; j < N; j++){
int Lest = X + (j+1);
mn[Q[j]] = min(mn[Q[j]],Lest);
}
int ANS;
int ansct = 0;
for (int i = 0; i < N; i++){
// printf("\n");
//printf("mxidx for %d = %d\n",i,mxidx);
if (mn[i] == T) {
ANS = i;
ansct++;
}
}
if (ansct == 1){
int i = ANS;
ans[i] = T;
Q[T-1] = i;
done[i] = 1;
break;
}
}
}
vector<int> ret;
for (int i = 0; i < N; i++){
ret.push_back(ans[i]);
}
return ret;
}
Compilation message
grid.cpp: In function 'std::vector<int> SortDisks(int)':
grid.cpp:46:24: warning: 'ANS' may be used uninitialized in this function [-Wmaybe-uninitialized]
ans[i] = T;
~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
8 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
384 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
384 KB |
Output is correct |
15 |
Correct |
11 ms |
384 KB |
Output is correct |
16 |
Correct |
12 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
8 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
384 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
384 KB |
Output is correct |
15 |
Correct |
11 ms |
384 KB |
Output is correct |
16 |
Correct |
12 ms |
256 KB |
Output is correct |
17 |
Incorrect |
18 ms |
384 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |