#define wiwihorz
#include "koala.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define ll long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#ifdef wiwihorz
#define print(a...)cerr<<"Line "<<__LINE__<<":",kout("["+string(#a)+"] = ", a)
void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1,class ... T2>void kout(T1 a,T2 ... e){cerr<<a<<" ",kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
int B[100], R[100];
const int P = 100;
void clean() {
rep(i, 0, P - 1) B[i] = 0;
rep(i, 0, P - 1) R[i] = 0;
}
int minValue(int N, int W) {
clean();
B[0] = 1;
playRound(B, R);
rep(i, 0, N - 1) {
if(R[i] == 0) return i;
}
return 0;
}
int maxValue(int N, int W) {
vector<int> v(N, 0);
iota(all(v), 0);
while(v.size() > 1) {
clean();
vprint(all(v));
int x = W / v.size();
for(auto i : v) B[i] = x;
playRound(B, R);
v.clear();
rep(i, 0, N - 1) if(R[i] > x) v.push_back(i);
}
return v[0];
}
int greaterValue(int N, int W) {
int l = 1, r = 9;
while(l <= r) {
int mid = (l + r) / 2;
clean();
B[0] = mid;
B[1] = mid;
playRound(B, R);
bool a = R[0] > mid;
bool b = R[1] > mid;
if(a && b) l = mid + 1;
else if(!a && !b) r = mid - 1;
else return a < b;
}
assert(0);
return 0;
}
int get_ans(int l, int r) {
rep(x, 1, P) {
vector<vector<int>> dp(P + 1, vector<int>(P + 1, 0));
vector<vector<int>> cnt(P + 1, vector<int>(P + 1, 0));
vector<int> v(P + 1, 1);
rep(i, l, r) v[i] = x + 1;
rep(i, 1, P) rep(j, 0, P) {
dp[i][j] = dp[i - 1][j];
cnt[i][j] = cnt[i - 1][j];
if(v[i] <= j && dp[i - 1][j - v[i]] + i > dp[i][j]) {
dp[i][j] = dp[i - 1][j - v[i]] + i;
cnt[i][j] = cnt[i - 1][j - v[i]] + (i <= r && i >= l);
}
}
if(cnt[P][P] < r - l + 1 && cnt[P][P]) return x;
}
assert(0);
}
void solve(int l, int r, int *P, vector<int> v) {
if(l == r) P[v[0]] = l;
else {
clean();
int x = get_ans(l, r);
print(l, r, x);
for(auto i : v) B[i] = x;
playRound(B, R);
vector<int> a, b;
for(auto i : v) {
if(R[i] > x) b.push_back(i);
else a.push_back(i);
}
assert(a.size());
assert(b.size());
solve(l, l + a.size() - 1, P, a);
solve(r - b.size() + 1, r, P, b);
}
}
void allValues(int N, int W, int *P) {
if(W == N) {
vector<int> v(N, 0);
iota(all(v), 0);
solve(1, N, P, v);
}
else {
vector<int> v(N, 0);
iota(all(v), 0);
stable_sort(all(v), [&](int a, int b){
clean();
B[a] = W / 2;
B[b] = W / 2;
playRound(B, R);
return R[a] <= W / 2;
});
rep(i, 0, N - 1) P[v[i]] = i + 1;
}
}
Compilation message
koala.cpp:6: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
6 | #pragma loop-opt(on)
|
koala.cpp:21:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
21 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
koala.cpp:21:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
21 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
448 KB |
Output is correct |
2 |
Correct |
61 ms |
336 KB |
Output is correct |
3 |
Correct |
60 ms |
456 KB |
Output is correct |
4 |
Correct |
56 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
320 KB |
Output is correct |
2 |
Correct |
58 ms |
328 KB |
Output is correct |
3 |
Correct |
49 ms |
332 KB |
Output is correct |
4 |
Correct |
47 ms |
328 KB |
Output is correct |
5 |
Correct |
51 ms |
336 KB |
Output is correct |
6 |
Correct |
51 ms |
324 KB |
Output is correct |
7 |
Correct |
48 ms |
336 KB |
Output is correct |
8 |
Correct |
51 ms |
324 KB |
Output is correct |
9 |
Correct |
47 ms |
332 KB |
Output is correct |
10 |
Correct |
47 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
208 KB |
Output is correct |
2 |
Correct |
40 ms |
288 KB |
Output is correct |
3 |
Correct |
35 ms |
308 KB |
Output is correct |
4 |
Correct |
34 ms |
208 KB |
Output is correct |
5 |
Correct |
31 ms |
208 KB |
Output is correct |
6 |
Correct |
31 ms |
208 KB |
Output is correct |
7 |
Correct |
30 ms |
320 KB |
Output is correct |
8 |
Correct |
31 ms |
208 KB |
Output is correct |
9 |
Correct |
30 ms |
208 KB |
Output is correct |
10 |
Correct |
29 ms |
208 KB |
Output is correct |
11 |
Correct |
35 ms |
208 KB |
Output is correct |
12 |
Correct |
15 ms |
320 KB |
Output is correct |
13 |
Correct |
32 ms |
296 KB |
Output is correct |
14 |
Correct |
30 ms |
208 KB |
Output is correct |
15 |
Correct |
28 ms |
320 KB |
Output is correct |
16 |
Correct |
28 ms |
208 KB |
Output is correct |
17 |
Correct |
28 ms |
208 KB |
Output is correct |
18 |
Correct |
28 ms |
208 KB |
Output is correct |
19 |
Correct |
28 ms |
208 KB |
Output is correct |
20 |
Correct |
30 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
456 KB |
Output is correct |
2 |
Correct |
20 ms |
336 KB |
Output is correct |
3 |
Correct |
20 ms |
336 KB |
Output is correct |
4 |
Correct |
19 ms |
336 KB |
Output is correct |
5 |
Correct |
19 ms |
416 KB |
Output is correct |
6 |
Correct |
19 ms |
412 KB |
Output is correct |
7 |
Correct |
18 ms |
420 KB |
Output is correct |
8 |
Correct |
19 ms |
416 KB |
Output is correct |
9 |
Correct |
18 ms |
420 KB |
Output is correct |
10 |
Correct |
18 ms |
416 KB |
Output is correct |
11 |
Correct |
18 ms |
336 KB |
Output is correct |
12 |
Correct |
19 ms |
416 KB |
Output is correct |
13 |
Correct |
19 ms |
416 KB |
Output is correct |
14 |
Correct |
19 ms |
336 KB |
Output is correct |
15 |
Correct |
18 ms |
336 KB |
Output is correct |
16 |
Correct |
18 ms |
420 KB |
Output is correct |
17 |
Correct |
17 ms |
420 KB |
Output is correct |
18 |
Correct |
17 ms |
420 KB |
Output is correct |
19 |
Correct |
19 ms |
416 KB |
Output is correct |
20 |
Correct |
25 ms |
336 KB |
Output is correct |
21 |
Correct |
19 ms |
468 KB |
Output is correct |
22 |
Correct |
20 ms |
416 KB |
Output is correct |
23 |
Correct |
18 ms |
416 KB |
Output is correct |
24 |
Correct |
20 ms |
336 KB |
Output is correct |
25 |
Correct |
18 ms |
336 KB |
Output is correct |
26 |
Correct |
18 ms |
420 KB |
Output is correct |
27 |
Correct |
16 ms |
416 KB |
Output is correct |
28 |
Correct |
20 ms |
384 KB |
Output is correct |
29 |
Correct |
18 ms |
336 KB |
Output is correct |
30 |
Correct |
19 ms |
408 KB |
Output is correct |
31 |
Correct |
19 ms |
420 KB |
Output is correct |
32 |
Correct |
22 ms |
356 KB |
Output is correct |
33 |
Correct |
19 ms |
412 KB |
Output is correct |
34 |
Correct |
17 ms |
336 KB |
Output is correct |
35 |
Correct |
17 ms |
416 KB |
Output is correct |
36 |
Correct |
24 ms |
336 KB |
Output is correct |
37 |
Correct |
18 ms |
416 KB |
Output is correct |
38 |
Correct |
19 ms |
464 KB |
Output is correct |
39 |
Correct |
22 ms |
416 KB |
Output is correct |
40 |
Correct |
18 ms |
416 KB |
Output is correct |