#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include"library.h"
using namespace std;
#define vel vector<int>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
void mmax(int &a, int b) { a = max(a, b); }
bool che(int i, int j, int n) {
vel a(n, 0);
a[i] = 1; a[j] = 1;
return Query(a) == 1;
}
void Solve(int n) {
if (n == 1) { vel res(1, 1); Answer(res); }
else {
vvel con(n);
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (che(i, j, n)) { con[i].push_back(j); con[j].push_back(i); }
}
}
int th;
for (int i = 0; i < n; i++) {
if (con[i].size() == 1) { th = i; }
}
veb seen(n, false);
seen[th] = true;
vel ans(1, th + 1);
th = con[th][0];
while (con[th].size() > 1) {
seen[th] = true;
ans.push_back(th + 1);
if (seen[con[th][0]]) { th = con[th][1]; }
else { th = con[th][0]; }
}
ans.push_back(th + 1);
Answer(ans);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
280 ms |
256 KB |
# of queries: 18336 |
2 |
Correct |
310 ms |
384 KB |
# of queries: 18145 |
3 |
Correct |
300 ms |
444 KB |
# of queries: 19900 |
4 |
Correct |
309 ms |
376 KB |
# of queries: 19900 |
5 |
Correct |
301 ms |
380 KB |
# of queries: 19900 |
6 |
Correct |
312 ms |
384 KB |
# of queries: 19900 |
7 |
Correct |
324 ms |
408 KB |
# of queries: 19900 |
8 |
Correct |
305 ms |
432 KB |
# of queries: 18528 |
9 |
Correct |
339 ms |
384 KB |
# of queries: 19701 |
10 |
Correct |
94 ms |
320 KB |
# of queries: 8256 |
11 |
Correct |
2 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
3 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
256 KB |
# of queries: 3 |
14 |
Correct |
2 ms |
256 KB |
# of queries: 6 |
15 |
Correct |
3 ms |
256 KB |
# of queries: 105 |
16 |
Correct |
8 ms |
384 KB |
# of queries: 351 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
280 ms |
256 KB |
# of queries: 18336 |
2 |
Correct |
310 ms |
384 KB |
# of queries: 18145 |
3 |
Correct |
300 ms |
444 KB |
# of queries: 19900 |
4 |
Correct |
309 ms |
376 KB |
# of queries: 19900 |
5 |
Correct |
301 ms |
380 KB |
# of queries: 19900 |
6 |
Correct |
312 ms |
384 KB |
# of queries: 19900 |
7 |
Correct |
324 ms |
408 KB |
# of queries: 19900 |
8 |
Correct |
305 ms |
432 KB |
# of queries: 18528 |
9 |
Correct |
339 ms |
384 KB |
# of queries: 19701 |
10 |
Correct |
94 ms |
320 KB |
# of queries: 8256 |
11 |
Correct |
2 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
3 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
256 KB |
# of queries: 3 |
14 |
Correct |
2 ms |
256 KB |
# of queries: 6 |
15 |
Correct |
3 ms |
256 KB |
# of queries: 105 |
16 |
Correct |
8 ms |
384 KB |
# of queries: 351 |
17 |
Execution timed out |
3004 ms |
256 KB |
Time limit exceeded |
18 |
Execution timed out |
3084 ms |
256 KB |
Time limit exceeded |
19 |
Execution timed out |
3018 ms |
384 KB |
Time limit exceeded |
20 |
Execution timed out |
3075 ms |
384 KB |
Time limit exceeded |
21 |
Execution timed out |
3005 ms |
512 KB |
Time limit exceeded |
22 |
Execution timed out |
3037 ms |
424 KB |
Time limit exceeded |
23 |
Execution timed out |
3013 ms |
356 KB |
Time limit exceeded |
24 |
Incorrect |
1097 ms |
256 KB |
Wrong Answer [3] |
25 |
Execution timed out |
3074 ms |
376 KB |
Time limit exceeded |
26 |
Execution timed out |
3009 ms |
376 KB |
Time limit exceeded |
27 |
Incorrect |
1142 ms |
384 KB |
Wrong Answer [3] |
28 |
Execution timed out |
3078 ms |
384 KB |
Time limit exceeded |
29 |
Execution timed out |
3045 ms |
352 KB |
Time limit exceeded |
30 |
Execution timed out |
3090 ms |
352 KB |
Time limit exceeded |