#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
void Solve(int N) {
vector<int> M(N, 1);
int st = 0;
vector<int> res;
vector<int> in(N);
for (int i = 0; i < N; ++i) {
M[i] = 0;
if (Query(M) == 1) {
res.push_back(i);
st = i;
in[st] = 1;
break;
}
M[i] = 1;
}
auto make = [&](vector<int> v) {
vector<int> ret(N);
for (int i : v) {
ret[i] = 1;
}
return ret;
};
for (int i = 1; i < N; ++i) {// == res.size() < n
vector<int> available;
for (int j = 0; j < N; ++j) {
if (!in[j] && j != st) {
available.push_back(j);
}
}
while (available.size() > 1) {
vector<int> ask;
for (int j = 0; j < (int) available.size() / 2; ++j) {
ask.push_back(available[j]);
}
int x = Query(make(ask));
ask.push_back(st);
int y = Query(make(ask));
ask.pop_back();
if (x != y) {
ask.clear();
for (int j = (int) available.size() / 2; j < (int) available.size(); ++j) {
ask.push_back(available[j]);
}
}
available = ask;
}
res.push_back(available[0]);
in[res.back()] = true;
st = res.back();
}
for (int i = 0; i < N; ++i) {
res[i]++;
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
692 KB |
# of queries: 2375 |
2 |
Correct |
20 ms |
696 KB |
# of queries: 2409 |
3 |
Correct |
25 ms |
432 KB |
# of queries: 2648 |
4 |
Correct |
21 ms |
692 KB |
# of queries: 2595 |
5 |
Correct |
23 ms |
696 KB |
# of queries: 2508 |
6 |
Correct |
21 ms |
692 KB |
# of queries: 2551 |
7 |
Correct |
24 ms |
444 KB |
# of queries: 2544 |
8 |
Correct |
15 ms |
948 KB |
# of queries: 2420 |
9 |
Correct |
18 ms |
692 KB |
# of queries: 2546 |
10 |
Correct |
10 ms |
688 KB |
# of queries: 1474 |
11 |
Runtime error |
0 ms |
436 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
692 KB |
# of queries: 2375 |
2 |
Correct |
20 ms |
696 KB |
# of queries: 2409 |
3 |
Correct |
25 ms |
432 KB |
# of queries: 2648 |
4 |
Correct |
21 ms |
692 KB |
# of queries: 2595 |
5 |
Correct |
23 ms |
696 KB |
# of queries: 2508 |
6 |
Correct |
21 ms |
692 KB |
# of queries: 2551 |
7 |
Correct |
24 ms |
444 KB |
# of queries: 2544 |
8 |
Correct |
15 ms |
948 KB |
# of queries: 2420 |
9 |
Correct |
18 ms |
692 KB |
# of queries: 2546 |
10 |
Correct |
10 ms |
688 KB |
# of queries: 1474 |
11 |
Runtime error |
0 ms |
436 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |