#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MX=500;
int B[MX], R[MX];
int minValue(int N, int W) {
RE(i,N) B[i] = 0;
B[1] = 1;
playRound(B,R);
RE(i,N) if(R[i] == 0) return i;
return 0;
}
int maxValue(int N, int W) {
vi possible;
RE(i,N) possible.push_back(i);
while(possible.size() > 1) {
int weight = W / possible.size();
RE(i,N) B[i] = 0;
FOR(u,possible) B[u] = weight;
playRound(B,R);
possible.clear();
RE(i,N) if(R[i] > weight) possible.push_back(i);
}
return possible[0];
}
int greaterValue(int N, int W, int i, int j) {
int lb=1, ub=10;
while(lb != ub) {
int mid=(lb+ub)/2;
RE(i,N) B[i] = 0;
B[i] = mid;
B[j] = mid;
playRound(B,R);
if(R[i] <= mid && R[j] <= mid) ub=mid-1;
if(R[i] > mid && R[j] > mid) lb=mid+1;
if(R[i] <= mid && R[j] > mid) return j;
if(R[i] > mid && R[j] <= mid) return i;
}
RE(i,N) B[i] = 0;
B[i] = lb;
B[j] = lb;
playRound(B,R);
if(R[i] <= lb && R[j] > lb) return j;
if(R[i] > lb && R[j] <= lb) return i;
return i;
}
int greaterValue(int N, int W) {
return greaterValue(N,W,0,1);
}
void findValues(int N, int W, int lb, int ub, vi f, int *P) {
if(f.size() == 1) {
P[f[0]] = lb;
return;
}
int weight = W / f.size();
RE(i,N) B[i] = 0;
FOR(u,f) B[u] = weight;
playRound(B,R);
vi left;
vi right;
FOR(u,f) (R[u] > weight ? right : left).push_back(u);
findValues(N,W,lb,lb+left.size()-1,left,P);
findValues(N,W,ub-right.size()+1,ub,right,P);
}
void allValues(int N, int W, int *P) {
vi f;
RE(i,N) f.push_back(i);
findValues(N,W,1,N,f,P);
if (W == 2*N) {
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
200 KB |
Output is correct |
2 |
Correct |
7 ms |
204 KB |
Output is correct |
3 |
Correct |
6 ms |
200 KB |
Output is correct |
4 |
Correct |
6 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
200 KB |
Output is correct |
2 |
Correct |
20 ms |
320 KB |
Output is correct |
3 |
Correct |
20 ms |
324 KB |
Output is correct |
4 |
Correct |
18 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
328 KB |
Output is correct |
2 |
Correct |
78 ms |
340 KB |
Output is correct |
3 |
Correct |
82 ms |
336 KB |
Output is correct |
4 |
Correct |
70 ms |
328 KB |
Output is correct |
5 |
Correct |
72 ms |
436 KB |
Output is correct |
6 |
Correct |
78 ms |
328 KB |
Output is correct |
7 |
Correct |
74 ms |
328 KB |
Output is correct |
8 |
Correct |
72 ms |
328 KB |
Output is correct |
9 |
Correct |
73 ms |
328 KB |
Output is correct |
10 |
Correct |
72 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
324 KB |
Output is correct |
2 |
Correct |
9 ms |
328 KB |
Output is correct |
3 |
Correct |
9 ms |
200 KB |
Output is correct |
4 |
Correct |
9 ms |
328 KB |
Output is correct |
5 |
Correct |
10 ms |
328 KB |
Output is correct |
6 |
Correct |
9 ms |
200 KB |
Output is correct |
7 |
Correct |
9 ms |
328 KB |
Output is correct |
8 |
Correct |
9 ms |
200 KB |
Output is correct |
9 |
Correct |
9 ms |
200 KB |
Output is correct |
10 |
Correct |
9 ms |
200 KB |
Output is correct |
11 |
Correct |
9 ms |
328 KB |
Output is correct |
12 |
Correct |
8 ms |
328 KB |
Output is correct |
13 |
Correct |
8 ms |
328 KB |
Output is correct |
14 |
Correct |
8 ms |
328 KB |
Output is correct |
15 |
Correct |
8 ms |
200 KB |
Output is correct |
16 |
Correct |
8 ms |
200 KB |
Output is correct |
17 |
Correct |
9 ms |
304 KB |
Output is correct |
18 |
Correct |
9 ms |
200 KB |
Output is correct |
19 |
Correct |
10 ms |
200 KB |
Output is correct |
20 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
134 ms |
1304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |