# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
61718 |
2018-07-26T12:26:32 Z |
mAng0 |
Library (JOI18_library) |
C++17 |
|
734 ms |
704 KB |
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
vector<int> global_M;
vector<int> ban;
vector<int> ans;
int n, last;
int task_one(int s, int e){
if(s == e) return s;
int mid = (s + e) / 2;
for(int i=0;i<n;i++) global_M[i] = 0;
for(int i=s;i<=mid;i++){
global_M[i] = 1;
}
int one = Query(global_M);
for(int i=0;i<n;i++) global_M[i] = 1 - global_M[i];
int two = Query(global_M);
if(one >= two) return task_one(s, mid);
else return task_one(mid+1, e);
}
int task_two(int s, int e){
if(s == e) return s;
int mid = (s + e) / 2;
for(int i=0;i<n;i++) global_M[i] = 0;
int cnt = 0;
for(int i=s;i<=mid;i++){
if(ban[i]) continue;
global_M[i] = 1;
cnt++;
}
if(cnt == 0) return task_two(mid+1, e);
int one = Query(global_M);
global_M[last] = 1;
int two = Query(global_M);
if(one == two) return task_two(s, mid);
else return task_two(mid+1, e);
}
void Solve(int N)
{
n = N;
global_M.resize(N);
ban.resize(N);
last = task_one(0, n-1);
//printf("hi, %d\n", last);
ban[last] = 1;
ans.push_back(last+1);
for(int i=0;i<n-1;i++){
last = task_two(0, n-1);
//printf("hii, %d\n", last);
ban[last] = 1;
ans.push_back(last+1);
}
Answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
248 KB |
Output is correct |
2 |
Correct |
61 ms |
372 KB |
Output is correct |
3 |
Correct |
51 ms |
384 KB |
Output is correct |
4 |
Correct |
68 ms |
488 KB |
Output is correct |
5 |
Correct |
61 ms |
488 KB |
Output is correct |
6 |
Correct |
67 ms |
488 KB |
Output is correct |
7 |
Correct |
48 ms |
488 KB |
Output is correct |
8 |
Correct |
78 ms |
488 KB |
Output is correct |
9 |
Correct |
71 ms |
488 KB |
Output is correct |
10 |
Correct |
33 ms |
488 KB |
Output is correct |
11 |
Correct |
2 ms |
488 KB |
Output is correct |
12 |
Correct |
3 ms |
496 KB |
Output is correct |
13 |
Correct |
2 ms |
496 KB |
Output is correct |
14 |
Correct |
3 ms |
496 KB |
Output is correct |
15 |
Correct |
5 ms |
496 KB |
Output is correct |
16 |
Correct |
6 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
248 KB |
Output is correct |
2 |
Correct |
61 ms |
372 KB |
Output is correct |
3 |
Correct |
51 ms |
384 KB |
Output is correct |
4 |
Correct |
68 ms |
488 KB |
Output is correct |
5 |
Correct |
61 ms |
488 KB |
Output is correct |
6 |
Correct |
67 ms |
488 KB |
Output is correct |
7 |
Correct |
48 ms |
488 KB |
Output is correct |
8 |
Correct |
78 ms |
488 KB |
Output is correct |
9 |
Correct |
71 ms |
488 KB |
Output is correct |
10 |
Correct |
33 ms |
488 KB |
Output is correct |
11 |
Correct |
2 ms |
488 KB |
Output is correct |
12 |
Correct |
3 ms |
496 KB |
Output is correct |
13 |
Correct |
2 ms |
496 KB |
Output is correct |
14 |
Correct |
3 ms |
496 KB |
Output is correct |
15 |
Correct |
5 ms |
496 KB |
Output is correct |
16 |
Correct |
6 ms |
496 KB |
Output is correct |
17 |
Correct |
661 ms |
704 KB |
Output is correct |
18 |
Correct |
681 ms |
704 KB |
Output is correct |
19 |
Correct |
717 ms |
704 KB |
Output is correct |
20 |
Correct |
711 ms |
704 KB |
Output is correct |
21 |
Correct |
635 ms |
704 KB |
Output is correct |
22 |
Correct |
734 ms |
704 KB |
Output is correct |
23 |
Correct |
686 ms |
704 KB |
Output is correct |
24 |
Correct |
257 ms |
704 KB |
Output is correct |
25 |
Correct |
726 ms |
704 KB |
Output is correct |
26 |
Correct |
641 ms |
704 KB |
Output is correct |
27 |
Correct |
225 ms |
704 KB |
Output is correct |
28 |
Correct |
374 ms |
704 KB |
Output is correct |
29 |
Correct |
431 ms |
704 KB |
Output is correct |
30 |
Correct |
330 ms |
704 KB |
Output is correct |