# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
409428 |
2021-05-20T17:43:13 Z |
Alma |
Library (JOI18_library) |
C++14 |
|
183 ms |
328 KB |
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N) {
vector<int> res;
if (N == 1) {
res = {1};
Answer(res);
}
else if (N == 2){
res = {1, 2};
Answer(res);
}
vector<int> M(N, 1);
int extremo = -1;
for (int i = 0; i < N; i++) {
M[i] = 0;
if (Query(M) == 1) {
extremo = i;
break;
}
M[i] = 1;
}
res.push_back(extremo+1);
M.assign(N, 0);
vector<bool> puesto(N, false);
puesto[extremo] = true;
int libro_izq = extremo;
while ((int)res.size() < N-1) {
for (int i = 0; i < N; i++) {
if (puesto[i]) continue;
M[libro_izq] = 1; M[i] = 1;
if (Query(M) == 1) {
res.push_back(i+1);
puesto[i] = true;
libro_izq = i;
break;
}
M[libro_izq] = 0; M[i] = 0;
}
}
for (int i = 0; i < N; i++) {
if (!puesto[i]) res.push_back(i+1);
}
Answer(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
276 KB |
# of queries: 9386 |
2 |
Correct |
161 ms |
276 KB |
# of queries: 9920 |
3 |
Correct |
156 ms |
320 KB |
# of queries: 10592 |
4 |
Correct |
169 ms |
272 KB |
# of queries: 9983 |
5 |
Correct |
131 ms |
280 KB |
# of queries: 10490 |
6 |
Correct |
124 ms |
272 KB |
# of queries: 9331 |
7 |
Correct |
140 ms |
268 KB |
# of queries: 10199 |
8 |
Correct |
180 ms |
268 KB |
# of queries: 9063 |
9 |
Correct |
115 ms |
268 KB |
# of queries: 10492 |
10 |
Correct |
60 ms |
284 KB |
# of queries: 4191 |
11 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
276 KB |
# of queries: 9386 |
2 |
Correct |
161 ms |
276 KB |
# of queries: 9920 |
3 |
Correct |
156 ms |
320 KB |
# of queries: 10592 |
4 |
Correct |
169 ms |
272 KB |
# of queries: 9983 |
5 |
Correct |
131 ms |
280 KB |
# of queries: 10490 |
6 |
Correct |
124 ms |
272 KB |
# of queries: 9331 |
7 |
Correct |
140 ms |
268 KB |
# of queries: 10199 |
8 |
Correct |
180 ms |
268 KB |
# of queries: 9063 |
9 |
Correct |
115 ms |
268 KB |
# of queries: 10492 |
10 |
Correct |
60 ms |
284 KB |
# of queries: 4191 |
11 |
Runtime error |
1 ms |
328 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |