#include "library.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll B) {
return (ull)rng() % B;
}
int n;
bool check(int x,int y){
vector <int> M(n);
M[x] = 1;
M[y] = 1;
return (Query(M) == 1);
}
void Solve(int N){
n = N;
vector<int> ans(N),fix(N),del(N);
for(int i = 0; i < N; i++) {
ans[i] = fix[i] = 0;
}
int l = 0,r = N - 1;
while (l <= r){
int tot = 0;
vector <int> M(N);
for (int i = 0; i < N; i++) {
M[i] = 1;
del[i] = 0;
if (fix[i]) M[i] = 0,del[i] = 1;
else ++tot;
}
if (l == r){
for (int i=0;i<N;i++){
if (M[i]) {
ans[l] = i;
break;
}
}
break;
}
int cnt = 0;
while (tot > 0){
int k;
while (1){
k = rnd(N);
if (del[k]) continue;
break;
}
del[k] = 1;
tot -= 1;
M[k] = 0;
if (Query(M) == 1){
++cnt;
if (cnt == 1) ans[l] = k;
else ans[r] = k;
fix[k] = 1;
}
if (cnt == 2) break;
M[k] = 1;
}
if (l && !check(ans[l - 1],ans[l])){
swap(ans[l],ans[r]);
}
l += 1;
r -= 1;
}
for (int i=0;i<N;i++)
ans[i] += 1;
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
344 KB |
# of queries: 6144 |
2 |
Correct |
50 ms |
592 KB |
# of queries: 6209 |
3 |
Correct |
65 ms |
344 KB |
# of queries: 6970 |
4 |
Correct |
68 ms |
344 KB |
# of queries: 6979 |
5 |
Correct |
60 ms |
344 KB |
# of queries: 6218 |
6 |
Correct |
66 ms |
344 KB |
# of queries: 6987 |
7 |
Correct |
61 ms |
344 KB |
# of queries: 6679 |
8 |
Correct |
63 ms |
344 KB |
# of queries: 6551 |
9 |
Correct |
46 ms |
344 KB |
# of queries: 6736 |
10 |
Correct |
28 ms |
344 KB |
# of queries: 2975 |
11 |
Correct |
0 ms |
344 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
344 KB |
# of queries: 2 |
13 |
Correct |
0 ms |
344 KB |
# of queries: 3 |
14 |
Correct |
0 ms |
344 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
344 KB |
# of queries: 52 |
16 |
Correct |
1 ms |
344 KB |
# of queries: 144 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
344 KB |
# of queries: 6144 |
2 |
Correct |
50 ms |
592 KB |
# of queries: 6209 |
3 |
Correct |
65 ms |
344 KB |
# of queries: 6970 |
4 |
Correct |
68 ms |
344 KB |
# of queries: 6979 |
5 |
Correct |
60 ms |
344 KB |
# of queries: 6218 |
6 |
Correct |
66 ms |
344 KB |
# of queries: 6987 |
7 |
Correct |
61 ms |
344 KB |
# of queries: 6679 |
8 |
Correct |
63 ms |
344 KB |
# of queries: 6551 |
9 |
Correct |
46 ms |
344 KB |
# of queries: 6736 |
10 |
Correct |
28 ms |
344 KB |
# of queries: 2975 |
11 |
Correct |
0 ms |
344 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
344 KB |
# of queries: 2 |
13 |
Correct |
0 ms |
344 KB |
# of queries: 3 |
14 |
Correct |
0 ms |
344 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
344 KB |
# of queries: 52 |
16 |
Correct |
1 ms |
344 KB |
# of queries: 144 |
17 |
Runtime error |
214 ms |
456 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |