#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
#define pf printf
#define pb push_back
#define sz(x) (int)x.size()
int n,w,b[105],r[105];
void reset(){
memset(b,0,sizeof b);
}
void play(){
playRound(b,r);
#ifdef DEBUG
for(int i=0;i<n;++i)pf("%2d ",b[i]);pf("\n");
for(int i=0;i<n;++i)pf("%2d ",r[i]);pf("\n");
#endif
}
int minValue(int N, int W) {
// TODO: Implement Subtask 2 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
n=N;
reset();
b[0]=1;
play();
int ans=0;
if(r[0]==2){
for(int i=0;i<n;++i)if(r[i]==0)ans=i;
}
return ans;
}
int maxValue(int N, int W) {
// TODO: Implement Subtask 2 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
n=N;
reset();
for(int i=0;i<n;++i)b[i]=1;
play();
reset();
for(int i=0;i<n;++i)if(r[i]==2)b[i]=2;
play();
reset();
for(int i=0;i<n;++i)if(r[i]==3)b[i]=4;
play();
reset();
for(int i=0;i<n;++i)if(r[i]==5)b[i]=11;
play();
for(int i=0;i<n;++i)if(r[i]==12)return i;
return 0;
}
int greaterValue(int N, int W) {
// TODO: Implement Subtask 3 solution here.
// You may leave this function unmodified if you are not attempting this
// subtask.
n=N;
int lo=1,hi=11,mid,res;
while(lo<=hi){
mid=(lo+hi)/2;
reset();
for(int i=0;i<2;++i)b[i]=mid;
play();
if(r[0]==0&&r[1]==0)hi=mid-1;
else if(r[0]>0&&r[1]>0)lo=mid+1;
else if(r[0]>r[1])return 0;
else return 1;
}
return 0;
}
void dnc(int lv,int rv,vector<int> &v,int *p){
if(lv==rv){
assert(sz(v)==1);
p[v[0]]=lv;
return;
}
reset();
for(int i:v)b[i]=w/sz(v);
play();
vector<int> tol,tor;
for(int i:v){
if(r[i]>b[i])tor.pb(i);
else tol.pb(i);
}
dnc(lv,lv+sz(tol)-1,tol,p);
dnc(lv+sz(tol),rv,tor,p);
}
int sqrt(int x){
for(int i=1;i<=10;++i){
if(i*i>=x)return i;
}
return 10;
}
void dnc2(int lv,int rv,vector<int> &v,int *p){
if(lv==rv){
assert(sz(v)==1);
p[v[0]]=lv;
return;
}
reset();
for(int i:v){
b[i]=min(sqrt(lv),w/sz(v));
}
play();
vector<int> tol,tor;
for(int i:v){
if(r[i]>b[i])tor.pb(i);
else tol.pb(i);
}
dnc2(lv,lv+sz(tol)-1,tol,p);
dnc2(lv+sz(tol),rv,tor,p);
}
void allValues(int N, int W, int *P) {
n=N;w=W;
if (W == 2*N) {
// TODO: Implement Subtask 4 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
vector<int> v;
for(int i=0;i<n;++i)v.pb(i);
dnc(1,n,v,P);
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
vector<int> v;
for(int i=0;i<n;++i)v.pb(i);
dnc2(1,n,v,P);
}
}
Compilation message
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:70:24: warning: unused variable 'res' [-Wunused-variable]
70 | int lo=1,hi=11,mid,res;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
200 KB |
Output is correct |
2 |
Correct |
4 ms |
316 KB |
Output is correct |
3 |
Correct |
4 ms |
200 KB |
Output is correct |
4 |
Correct |
4 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
312 KB |
Output is correct |
2 |
Correct |
11 ms |
200 KB |
Output is correct |
3 |
Correct |
13 ms |
312 KB |
Output is correct |
4 |
Correct |
12 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
328 KB |
Output is correct |
2 |
Correct |
50 ms |
312 KB |
Output is correct |
3 |
Correct |
46 ms |
324 KB |
Output is correct |
4 |
Correct |
45 ms |
324 KB |
Output is correct |
5 |
Correct |
47 ms |
328 KB |
Output is correct |
6 |
Correct |
44 ms |
328 KB |
Output is correct |
7 |
Correct |
44 ms |
316 KB |
Output is correct |
8 |
Correct |
46 ms |
324 KB |
Output is correct |
9 |
Correct |
44 ms |
328 KB |
Output is correct |
10 |
Correct |
44 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
200 KB |
Output is correct |
2 |
Correct |
5 ms |
200 KB |
Output is correct |
3 |
Correct |
6 ms |
316 KB |
Output is correct |
4 |
Correct |
5 ms |
200 KB |
Output is correct |
5 |
Correct |
6 ms |
200 KB |
Output is correct |
6 |
Correct |
6 ms |
200 KB |
Output is correct |
7 |
Correct |
6 ms |
324 KB |
Output is correct |
8 |
Correct |
6 ms |
200 KB |
Output is correct |
9 |
Correct |
6 ms |
200 KB |
Output is correct |
10 |
Correct |
5 ms |
200 KB |
Output is correct |
11 |
Correct |
5 ms |
200 KB |
Output is correct |
12 |
Correct |
5 ms |
200 KB |
Output is correct |
13 |
Correct |
6 ms |
200 KB |
Output is correct |
14 |
Correct |
5 ms |
200 KB |
Output is correct |
15 |
Correct |
5 ms |
200 KB |
Output is correct |
16 |
Correct |
5 ms |
200 KB |
Output is correct |
17 |
Correct |
5 ms |
200 KB |
Output is correct |
18 |
Correct |
5 ms |
200 KB |
Output is correct |
19 |
Correct |
5 ms |
312 KB |
Output is correct |
20 |
Correct |
5 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
312 KB |
Output is correct |
2 |
Correct |
3 ms |
200 KB |
Output is correct |
3 |
Correct |
3 ms |
200 KB |
Output is correct |
4 |
Correct |
4 ms |
200 KB |
Output is correct |
5 |
Correct |
3 ms |
200 KB |
Output is correct |
6 |
Correct |
3 ms |
200 KB |
Output is correct |
7 |
Correct |
3 ms |
200 KB |
Output is correct |
8 |
Correct |
3 ms |
200 KB |
Output is correct |
9 |
Correct |
3 ms |
200 KB |
Output is correct |
10 |
Correct |
3 ms |
200 KB |
Output is correct |
11 |
Correct |
3 ms |
200 KB |
Output is correct |
12 |
Correct |
3 ms |
200 KB |
Output is correct |
13 |
Correct |
3 ms |
200 KB |
Output is correct |
14 |
Correct |
3 ms |
200 KB |
Output is correct |
15 |
Correct |
3 ms |
200 KB |
Output is correct |
16 |
Correct |
3 ms |
200 KB |
Output is correct |
17 |
Correct |
3 ms |
200 KB |
Output is correct |
18 |
Correct |
3 ms |
200 KB |
Output is correct |
19 |
Correct |
3 ms |
200 KB |
Output is correct |
20 |
Correct |
3 ms |
200 KB |
Output is correct |
21 |
Correct |
3 ms |
200 KB |
Output is correct |
22 |
Correct |
3 ms |
200 KB |
Output is correct |
23 |
Correct |
5 ms |
200 KB |
Output is correct |
24 |
Correct |
3 ms |
308 KB |
Output is correct |
25 |
Correct |
3 ms |
200 KB |
Output is correct |
26 |
Correct |
3 ms |
200 KB |
Output is correct |
27 |
Correct |
3 ms |
200 KB |
Output is correct |
28 |
Correct |
4 ms |
312 KB |
Output is correct |
29 |
Correct |
3 ms |
200 KB |
Output is correct |
30 |
Correct |
3 ms |
200 KB |
Output is correct |
31 |
Correct |
3 ms |
200 KB |
Output is correct |
32 |
Correct |
3 ms |
200 KB |
Output is correct |
33 |
Correct |
3 ms |
200 KB |
Output is correct |
34 |
Correct |
3 ms |
200 KB |
Output is correct |
35 |
Correct |
3 ms |
200 KB |
Output is correct |
36 |
Correct |
3 ms |
200 KB |
Output is correct |
37 |
Correct |
3 ms |
200 KB |
Output is correct |
38 |
Correct |
3 ms |
200 KB |
Output is correct |
39 |
Correct |
4 ms |
200 KB |
Output is correct |
40 |
Correct |
3 ms |
200 KB |
Output is correct |