#include "koala.h"
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define sz(x) (int)(x.size() )
using namespace std ;
int b[100] , r[100] ;
void clean() { for(int i = 0 ; i < 100 ; i++ ) b[i] = 0 ; }
int minValue(int N, int W)
{
clean() ;
b[0] = 1 ;
playRound(b, r) ;
if(r[0] < 2 ) return 0 ;
for(int i = 1 ; i< 100 ; i++ )
if( !r[i] ) return i ;
}
int maxValue(int N, int W)
{
vector<int> v(N) ; iota(all(v),0) ;
vector<int> aux ;
while( sz(v) > 1 )
{
clean() ;
for(auto e : v ) b[e] = 100/sz(v) ;
playRound(b, r) ;
aux.clear() ;
for(auto e : v )
if( r[e] > b[e] ) aux.push_back(e) ;
swap(v,aux) ;
}
return v[0] ;
}
int greaterValue(int N, int W)
{
clean() ;
b[0] = b[1] = 5 ;
playRound(b,r) ;
if( (b[0] < r[0] ) != (b[1] < r[1] ) ) return (b[1] < r[1] ) ;
if( b[0] < r[0] )
{
b[0] = b[1] = 7 ;
playRound(b,r) ;
if( (b[0] < r[0] ) != (b[1] < r[1] ) ) return (b[1] < r[1] ) ;
b[0] = b[1] = 8 ;
playRound(b,r) ;
return (b[1] < r[1] ) ;
}
else
{
b[0] = b[1] = 2 ;
playRound(b,r) ;
if( (b[0] < r[0] ) != (b[1] < r[1] ) ) return (b[1] < r[1] ) ;
if(b[0] < r[0] )
{
b[0] = b[1] = 3 ;
playRound(b,r) ;
return (b[1] < r[1] ) ;
}
else
{
b[0] = b[1] = 1 ;
playRound(b,r) ;
return (b[1] < r[1] ) ;
}
}
}
bool isLarger(int x , int y, int t = 100 )
{
clean() ;
b[x] = b[y] = t ;
playRound(b,r) ;
return (b[x] < r[x] ) ;
}
vector<int> solve(vector<int> idx , int x )
{
vector<int> v = {idx[0], idx[1] } ;
if( isLarger(idx[0], idx[1], x ) ) swap(v[0], v[1] );
for(int i = 2 ; i < sz(idx) ; i++ )
{
int l = 0 , r = sz(v)-1 , mid , best = -1 ;
while( l <= r )
{
mid = (l+r)>>1 ;
if( isLarger(idx[i], v[mid],x ) )
{
best = mid ;
l = mid+1 ;
}
else r = mid-1 ;
}
vector<int> newV ;
if( best == -1 ) newV.push_back(idx[i]) ;
for(int j = 0 ; j < sz(v) ; j++ )
{
newV.push_back(v[j] ) ;
if( j == best ) newV.push_back( idx[i] ) ;
}
swap(newV, v) ;
}
return v ;
}
void allValues(int N, int W, int *P)
{
if (W == 2*N)
{
vector<int> idx(N) ; iota(all(idx),0) ;
vector<int> v = solve(idx, 100 ) ;
for(int i = 0 ; i < N ; i++ ) P[ v[i] ] = i+1 ;
}
else
{
for(int i = 0 ; i < N ; i++ ) P[i] = 0 ;
for(int i = 0 ; i < N ; i++ ) b[i] = 1 ;
playRound(b,r) ;
for(int i = 0 ; i < N ; i++ )
b[i] = (b[i] < r[i] ) ? 2 : 0 ;
playRound(b,r) ;
vector< vector<int> > quarters(4,vector<int>() ) ;
for(int i = 0 ; i< N ; i++ )
{
if( b[i] == 2 )
{
if( b[i] < r[i] ) quarters[3].push_back(i) ;
else quarters[2].push_back(i) ;
}
else
{
if( b[i] < r[i] ) quarters[1].push_back(i);
else quarters[0].push_back(i) ;
}
}
for(int i = 0 ; i < 4 ; i++ ) random_shuffle(all(quarters[i] ) ) ;
clean() ;
for(int i = 0 ; i < sz(quarters[3] ) ; i++ )
{
b[ quarters[3][i] ] = 1 ;
playRound(b,r) ;
for(int j = 0 ; j < N ; j++ )
if( P[j] == 0 && (b[j] >= r[j] ) ) P[j] = i+1 ;
}
vector<int> beg = {26,51,76} ;
for(int i = 1 , x = 6 ; i < 4 ; i++, x++ )
{
vector<int> t = solve(quarters[i], x ) ;
for(int j = beg[i-1] , k = 0 ; k < sz(t) ; k++ , j++ )
P[ t[k] ] = j ;
}
}
}
Compilation message
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
25 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Output is correct |
2 |
Correct |
6 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
5 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
364 KB |
Output is correct |
2 |
Correct |
18 ms |
384 KB |
Output is correct |
3 |
Correct |
18 ms |
364 KB |
Output is correct |
4 |
Correct |
18 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
364 KB |
Output is correct |
2 |
Correct |
86 ms |
492 KB |
Output is correct |
3 |
Correct |
72 ms |
364 KB |
Output is correct |
4 |
Correct |
72 ms |
364 KB |
Output is correct |
5 |
Correct |
74 ms |
364 KB |
Output is correct |
6 |
Correct |
75 ms |
364 KB |
Output is correct |
7 |
Correct |
73 ms |
384 KB |
Output is correct |
8 |
Correct |
73 ms |
364 KB |
Output is correct |
9 |
Correct |
73 ms |
384 KB |
Output is correct |
10 |
Correct |
72 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
492 KB |
Output is correct |
2 |
Correct |
44 ms |
364 KB |
Output is correct |
3 |
Correct |
43 ms |
364 KB |
Output is correct |
4 |
Correct |
43 ms |
364 KB |
Output is correct |
5 |
Correct |
44 ms |
364 KB |
Output is correct |
6 |
Correct |
44 ms |
492 KB |
Output is correct |
7 |
Correct |
43 ms |
364 KB |
Output is correct |
8 |
Correct |
44 ms |
420 KB |
Output is correct |
9 |
Correct |
44 ms |
364 KB |
Output is correct |
10 |
Correct |
44 ms |
364 KB |
Output is correct |
11 |
Correct |
44 ms |
364 KB |
Output is correct |
12 |
Correct |
39 ms |
364 KB |
Output is correct |
13 |
Correct |
43 ms |
364 KB |
Output is correct |
14 |
Correct |
41 ms |
364 KB |
Output is correct |
15 |
Correct |
43 ms |
364 KB |
Output is correct |
16 |
Correct |
42 ms |
364 KB |
Output is correct |
17 |
Correct |
42 ms |
364 KB |
Output is correct |
18 |
Correct |
42 ms |
364 KB |
Output is correct |
19 |
Correct |
43 ms |
364 KB |
Output is correct |
20 |
Correct |
42 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
2 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
3 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
4 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
5 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
6 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
7 |
Partially correct |
13 ms |
364 KB |
Output is partially correct |
8 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
9 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
10 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
11 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
12 |
Partially correct |
11 ms |
364 KB |
Output is partially correct |
13 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
14 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
15 |
Partially correct |
11 ms |
364 KB |
Output is partially correct |
16 |
Partially correct |
12 ms |
384 KB |
Output is partially correct |
17 |
Partially correct |
12 ms |
376 KB |
Output is partially correct |
18 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
19 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
20 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
21 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
22 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
23 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
24 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
25 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
26 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
27 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
28 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
29 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
30 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
31 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
32 |
Partially correct |
12 ms |
392 KB |
Output is partially correct |
33 |
Partially correct |
13 ms |
492 KB |
Output is partially correct |
34 |
Partially correct |
12 ms |
492 KB |
Output is partially correct |
35 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
36 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
37 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
38 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
39 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |
40 |
Partially correct |
12 ms |
364 KB |
Output is partially correct |