#include<bits/stdc++.h>
#define MAXN 107
#include "koala.h"
using namespace std;
int b[MAXN],r[MAXN];
int minValue(int N, int W) {
b[0]=1;
playRound(b,r);
for(int i=0;i<N;i++){
if(r[i]==0)return i;
}
return 0;
}
vector<int> can,best;
void reset(){
best.clear(); can.clear();
for(int i=0;i<100;i++)b[i]=0;
}
int maxValue(int N, int W) {
reset();
for(int i=0;i<50;i++){
b[i]=2;
}
playRound(b,r);
for(int i=0;i<50;i++){
if(r[i]>=3)can.push_back(i);
}
for(int i=0;i<100;i++){
if(i<50)b[i]=0;
else b[i]=2;
}
playRound(b,r);
for(int i=50;i<100;i++){
if(r[i]>=3)can.push_back(i);
}
for(int i=0;i<100;i++)b[i]=0;
cout<<can.size()<<":\n";
for(int i:can)b[i]=3;
playRound(b,r);
for(int i:can){
if(r[i]>=4)best.push_back(i);
}
for(int i=0;i<100;i++)b[i]=0;
for(int i:best)b[i]=7;
playRound(b,r);
for(int i:best){
if(r[i]>=8)return i;
}
}
bool compare(int x,int y){
for(int i=0;i<100;i++)b[i]=0;
int ll=0,rr=10,tt;
while(ll+1<rr){
tt=(ll+rr)/2;
b[x]=b[y]=tt;
playRound(b,r);
if(r[x]<tt and r[y]<tt){
rr=tt;
}else if(r[x]>=tt and r[y]>=tt){
ll=tt;
}else{
if(r[x]>=tt)return false;
else return true;
}
}
return false;
}
int greaterValue(int N, int W) {
if(compare(0,1))return 1;
else return 0;
}
int order[MAXN];
void allValues(int N, int W, int *P) {
for(int i=0;i<N;i++){
order[i]=i;
}
sort(order,order+1,compare);
for(int i=0;i<N;i++){
P[order[i]]=i+1;
}
}
Compilation message
koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
480 KB |
Output is correct |
2 |
Correct |
46 ms |
344 KB |
Output is correct |
3 |
Correct |
39 ms |
344 KB |
Output is correct |
4 |
Correct |
37 ms |
344 KB |
Output is correct |
5 |
Correct |
38 ms |
352 KB |
Output is correct |
6 |
Correct |
39 ms |
492 KB |
Output is correct |
7 |
Correct |
38 ms |
344 KB |
Output is correct |
8 |
Correct |
38 ms |
484 KB |
Output is correct |
9 |
Correct |
38 ms |
344 KB |
Output is correct |
10 |
Correct |
37 ms |
352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |