#include <assert.h>
#include <iostream>
#include <algorithm>
#include "koala.h"
using namespace std;
int minValue(int N, int W) {
int B[N],R[N];
fill(B,B+N,0);
B[0]=1;
playRound(B,R);
int res=0;
for(int i=0;i<N;i++)
if(R[i]==0)
res=i;
return res;
}
int maxValue(int N, int W) {
int B[N],R[N];
int V[N];
fill(V,V+N,1);
fill(B,B+N,0);
fill(R,R+N,0);
int res=N;
while(true){
int k=(int)(N/res);
for(int i=0;i<N;i++)
B[i]=V[i]*k;
//for(int i=0;i<N;i++)cout<<B[i]<<" ";cout<<endl;
playRound(B,R);
res=0;
for(int i=0;i<N;i++){
if(V[i] and !R[i])
V[i]=false;
if(V[i] and R[i])
res++;
}
if(res==1)
for(int i=0;i<N;i++)
if(V[i] and R[i])
return i;
assert(res);
}
}
int greaterValue(int N, int W) {
int B[N],R[N];
fill(B,B+N,0);
fill(R,R+N,0);
int l=0,r=10,m;
while(l<r){
m=(l+r)/2;
B[0]=B[1]=m;
playRound(B,R);
if(R[0]!=R[1])
return R[0]<R[1];
if(R[0]==0)
r=m;
else
l=m+1;
}
}
int N;
bool comp(int a, int b){
int B[N],R[N];
fill(B,B+N,0);
fill(R,R+N,0);
int l=0,r=min(N,10),m;
while(l<r){
m=(l+r)/2;
B[a]=B[b]=m;
playRound(B,R);
if(R[a]!=R[b])
return R[a]<R[b];
if(R[a]==0)
r=m;
else
l=m+1;
}
}
void allValues(int N_, int W, int *P) {
N=N_;
int A[N];
for(int i=0;i<N;i++)
A[i]=i;
sort(A,A+N,comp);
for(int i=0;i<N;i++)
P[A[i]]=i+1;
}
Compilation message
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:88:1: warning: control reaches end of non-void function [-Wreturn-type]
88 | }
| ^
koala.cpp: In function 'bool comp(int, int)':
koala.cpp:116:1: warning: control reaches end of non-void function [-Wreturn-type]
116 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
452 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
344 KB |
Output is correct |
2 |
Correct |
10 ms |
448 KB |
Output is correct |
3 |
Correct |
11 ms |
344 KB |
Output is correct |
4 |
Correct |
10 ms |
704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
480 KB |
Output is correct |
2 |
Correct |
43 ms |
472 KB |
Output is correct |
3 |
Correct |
40 ms |
464 KB |
Output is correct |
4 |
Correct |
39 ms |
460 KB |
Output is correct |
5 |
Correct |
40 ms |
468 KB |
Output is correct |
6 |
Correct |
47 ms |
468 KB |
Output is correct |
7 |
Correct |
39 ms |
460 KB |
Output is correct |
8 |
Correct |
40 ms |
464 KB |
Output is correct |
9 |
Correct |
44 ms |
472 KB |
Output is correct |
10 |
Correct |
39 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
23 ms |
344 KB |
Output is partially correct |
2 |
Partially correct |
29 ms |
344 KB |
Output is partially correct |
3 |
Partially correct |
33 ms |
436 KB |
Output is partially correct |
4 |
Partially correct |
27 ms |
428 KB |
Output is partially correct |
5 |
Partially correct |
29 ms |
344 KB |
Output is partially correct |
6 |
Partially correct |
26 ms |
344 KB |
Output is partially correct |
7 |
Partially correct |
26 ms |
344 KB |
Output is partially correct |
8 |
Partially correct |
30 ms |
344 KB |
Output is partially correct |
9 |
Partially correct |
28 ms |
344 KB |
Output is partially correct |
10 |
Partially correct |
28 ms |
344 KB |
Output is partially correct |
11 |
Partially correct |
26 ms |
344 KB |
Output is partially correct |
12 |
Partially correct |
21 ms |
600 KB |
Output is partially correct |
13 |
Partially correct |
34 ms |
344 KB |
Output is partially correct |
14 |
Partially correct |
26 ms |
680 KB |
Output is partially correct |
15 |
Partially correct |
25 ms |
344 KB |
Output is partially correct |
16 |
Partially correct |
27 ms |
344 KB |
Output is partially correct |
17 |
Partially correct |
30 ms |
344 KB |
Output is partially correct |
18 |
Partially correct |
36 ms |
428 KB |
Output is partially correct |
19 |
Partially correct |
27 ms |
444 KB |
Output is partially correct |
20 |
Partially correct |
28 ms |
344 KB |
Output is partially correct |
21 |
Partially correct |
28 ms |
448 KB |
Output is partially correct |
22 |
Partially correct |
34 ms |
344 KB |
Output is partially correct |
23 |
Partially correct |
22 ms |
344 KB |
Output is partially correct |
24 |
Partially correct |
34 ms |
344 KB |
Output is partially correct |
25 |
Partially correct |
27 ms |
344 KB |
Output is partially correct |
26 |
Partially correct |
29 ms |
344 KB |
Output is partially correct |
27 |
Partially correct |
27 ms |
344 KB |
Output is partially correct |
28 |
Partially correct |
28 ms |
344 KB |
Output is partially correct |
29 |
Partially correct |
29 ms |
344 KB |
Output is partially correct |
30 |
Partially correct |
27 ms |
344 KB |
Output is partially correct |
31 |
Partially correct |
26 ms |
344 KB |
Output is partially correct |
32 |
Partially correct |
27 ms |
356 KB |
Output is partially correct |
33 |
Partially correct |
33 ms |
448 KB |
Output is partially correct |
34 |
Partially correct |
24 ms |
344 KB |
Output is partially correct |
35 |
Partially correct |
31 ms |
344 KB |
Output is partially correct |
36 |
Partially correct |
26 ms |
596 KB |
Output is partially correct |
37 |
Partially correct |
27 ms |
344 KB |
Output is partially correct |
38 |
Partially correct |
26 ms |
344 KB |
Output is partially correct |
39 |
Partially correct |
27 ms |
432 KB |
Output is partially correct |
40 |
Partially correct |
29 ms |
344 KB |
Output is partially correct |