Submission #756145

# Submission time Handle Problem Language Result Execution time Memory
756145 2023-06-11T08:10:21 Z AliHasanli Library (JOI18_library) C++17
100 / 100
353 ms 296 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
 
void Solve(int N)
{
	vector<int> vec(N), res(N);
	for (int i = 0, pre; i < N; ++i) {
		int l = 0, r = N - 1;
		while (l < r) {
			int m = l + r >> 1;
			int t, a, b;
			vector<int> v = vec;
			fill(v.begin() + l, v.begin() + m + 1, 1);
			a = Query(v);
			if (i == 0) {
				for (auto &j: v) j ^= 1;
				if (accumulate(v.begin(), v.end(), 0)) b = Query(v);
				else b = 0;
				t = a >= b;
			}
			else {
				v[pre] = 0;
				if (accumulate(v.begin(), v.end(), 0)) b = Query(v);
				else b = 0;
				if (i == 1) t = a == b;
				else t = a < b;
			}
			if (t) r = m;
			else l = m + 1;
		}
		vec[l] = 1;
		pre = l;
		res[i] = l + 1;
	}
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:11:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   11 |    int m = l + r >> 1;
      |            ~~^~~
library.cpp:23:10: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |     v[pre] = 0;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 50 ms 296 KB # of queries: 2944
2 Correct 45 ms 208 KB # of queries: 2926
3 Correct 47 ms 208 KB # of queries: 3088
4 Correct 45 ms 208 KB # of queries: 3088
5 Correct 43 ms 208 KB # of queries: 3088
6 Correct 37 ms 208 KB # of queries: 3088
7 Correct 55 ms 208 KB # of queries: 3088
8 Correct 42 ms 208 KB # of queries: 2962
9 Correct 45 ms 208 KB # of queries: 3070
10 Correct 26 ms 208 KB # of queries: 1810
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 3
13 Correct 1 ms 208 KB # of queries: 10
14 Correct 2 ms 212 KB # of queries: 16
15 Correct 3 ms 208 KB # of queries: 118
16 Correct 4 ms 208 KB # of queries: 260
# Verdict Execution time Memory Grader output
1 Correct 50 ms 296 KB # of queries: 2944
2 Correct 45 ms 208 KB # of queries: 2926
3 Correct 47 ms 208 KB # of queries: 3088
4 Correct 45 ms 208 KB # of queries: 3088
5 Correct 43 ms 208 KB # of queries: 3088
6 Correct 37 ms 208 KB # of queries: 3088
7 Correct 55 ms 208 KB # of queries: 3088
8 Correct 42 ms 208 KB # of queries: 2962
9 Correct 45 ms 208 KB # of queries: 3070
10 Correct 26 ms 208 KB # of queries: 1810
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 3
13 Correct 1 ms 208 KB # of queries: 10
14 Correct 2 ms 212 KB # of queries: 16
15 Correct 3 ms 208 KB # of queries: 118
16 Correct 4 ms 208 KB # of queries: 260
17 Correct 299 ms 208 KB # of queries: 19952
18 Correct 334 ms 208 KB # of queries: 19710
19 Correct 284 ms 208 KB # of queries: 19952
20 Correct 310 ms 208 KB # of queries: 18676
21 Correct 324 ms 208 KB # of queries: 17598
22 Correct 286 ms 208 KB # of queries: 19952
23 Correct 351 ms 248 KB # of queries: 19930
24 Correct 141 ms 208 KB # of queries: 9238
25 Correct 238 ms 208 KB # of queries: 19490
26 Correct 319 ms 208 KB # of queries: 18258
27 Correct 91 ms 208 KB # of queries: 9196
28 Correct 353 ms 208 KB # of queries: 19951
29 Correct 322 ms 208 KB # of queries: 19929
30 Correct 335 ms 208 KB # of queries: 19951