#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N){
set<int> p;
vector<int> q(N, 1);
vector<int> q1(N, 0);
for(int i = 1; i <= N; i ++) p.insert(i);
vector<int> l, r;
while((int)p.size() > 1){
int x = -1;
int y = -1;
for(auto X: p){
if(x != -1 && y != -1) break;
q[X - 1] = 0;
if(Query(q) == 1){
if(x == -1) x = X;
else if(y == -1) y = X;
}
q[X - 1] = 1;
}
if(!l.empty()){
int z = x;
q1[z - 1] = 1;
q1[l.back() - 1] = 1;
if(Query(q1) == 2) swap(x, y);
q1[z - 1] = 0;
q1[l.back() - 1] = 0;
}
l.push_back(x);
r.push_back(y);
p.erase(x);
p.erase(y);
q[x - 1] = 0;
q[y - 1] = 0;
}
if(!p.empty()) l.push_back(*p.begin());
vector<int> res;
for(int i = 0; i < (int)l.size(); i ++) res.push_back(l[i]);
for(int i = (int)r.size() - 1; i >= 0; i --) res.push_back(r[i]);
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
139 ms |
256 KB |
# of queries: 6271 |
2 |
Correct |
150 ms |
384 KB |
# of queries: 6123 |
3 |
Correct |
200 ms |
384 KB |
# of queries: 7304 |
4 |
Correct |
76 ms |
384 KB |
# of queries: 6996 |
5 |
Correct |
110 ms |
384 KB |
# of queries: 7004 |
6 |
Correct |
111 ms |
256 KB |
# of queries: 6587 |
7 |
Correct |
152 ms |
256 KB |
# of queries: 6841 |
8 |
Correct |
97 ms |
384 KB |
# of queries: 6334 |
9 |
Correct |
95 ms |
256 KB |
# of queries: 6796 |
10 |
Correct |
59 ms |
256 KB |
# of queries: 2891 |
11 |
Correct |
1 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
256 KB |
# of queries: 2 |
13 |
Correct |
1 ms |
256 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
256 KB |
# of queries: 55 |
16 |
Correct |
5 ms |
376 KB |
# of queries: 137 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
139 ms |
256 KB |
# of queries: 6271 |
2 |
Correct |
150 ms |
384 KB |
# of queries: 6123 |
3 |
Correct |
200 ms |
384 KB |
# of queries: 7304 |
4 |
Correct |
76 ms |
384 KB |
# of queries: 6996 |
5 |
Correct |
110 ms |
384 KB |
# of queries: 7004 |
6 |
Correct |
111 ms |
256 KB |
# of queries: 6587 |
7 |
Correct |
152 ms |
256 KB |
# of queries: 6841 |
8 |
Correct |
97 ms |
384 KB |
# of queries: 6334 |
9 |
Correct |
95 ms |
256 KB |
# of queries: 6796 |
10 |
Correct |
59 ms |
256 KB |
# of queries: 2891 |
11 |
Correct |
1 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
256 KB |
# of queries: 2 |
13 |
Correct |
1 ms |
256 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
1 ms |
256 KB |
# of queries: 55 |
16 |
Correct |
5 ms |
376 KB |
# of queries: 137 |
17 |
Execution timed out |
3060 ms |
432 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |