#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("O2")
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=100+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-6;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
out<<P.f<<' '<<P.s;
return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?" ":"");
return out;
}
ll mult(ll a,ll b){
return a*b%MOD;
}
ll mypow(ll a,ll b){
a%=MOD;
if(a==0) return 0;
if(b<=0) return 1;
ll res=1LL;
while(b){
if(b&1) res=(res*a)%MOD;
a=(a*a)%MOD;
b>>=1;
}
return res;
}
int play[105],ans[105];
int minValue(int n, int w) {
REP(i,n) play[i]=0;
play[0]=1;
playRound(play,ans);
REP(i,n){
if(!ans[i]){
return i;
}
}
}
int maxValue(int n, int W) {
vector<int> v;
REP(i,n) v.pb(i);
while(sz(v)>1){
REP(i,n) play[i]=0;
for(int x:v) play[x]=W/sz(v);
playRound(play,ans);
vector<int> vv;
for(int i:v) if(ans[i]) vv.pb(i);
v=vv;
}
return v[0];
}
int n,w;
//a less than b
bool cmp(int a,int b){
REP(i,n) play[i]=0;
if(w==200){
play[a]=100,play[b]=100;
playRound(play,ans);
if(ans[a]) return false;
return true;
}
int l=1,r=9;
while(l<r){
int mid=(l+r)/2;
play[a]=mid,play[b]=mid;
playRound(play,ans);
if(ans[a] and ans[b]) l=mid+1;
else{
if(ans[a]){
return 0;
}
if(ans[b]){
return 1;
}
r=mid-1;
}
}
}
int greaterValue(int N, int W) {
n=N;
return cmp(0,1);
}
int arr[maxn],tmp[maxn];
void srt(vector<int> &v,int l,int r,int *P){
if(l==r){
P[v[0]]=l;
}
else{
int x=min((int)sqrt(2*l),w/(r-l+1));
assert(x>0);
REP(i,n) play[i]=0;
for(int a:v) play[a]=x;
playRound(play,ans);
vector<int> vl,vr;
for(int a:v){
if(ans[a]) vr.pb(a);
else vl.pb(a);
}
srt(vl,l,l+sz(vl)-1,P);
srt(vr,l+sz(vl),r,P);
}
}
void srt(int l,int r){
if(l==r) return;
int mid=(l+r)/2;
srt(l,mid),srt(mid+1,r);
int p1=l,p2=mid+1;
int p3=l;
while(p1<=mid and p2<=r){
if(cmp(arr[p1],arr[p2])) tmp[p3++]=arr[p1++];
else tmp[p3++]=arr[p2++];
}
while(p1<=mid) tmp[p3++]=arr[p1++];
while(p2<=r) tmp[p3++]=arr[p2++];
for(int i=l;i<=r;i++) arr[i]=tmp[i];
}
void allValues(int N, int W, int *P) {
n=N,w=W;
if(w==2*n){
REP(i,n) arr[i]=i;
srt(0,n-1);
REP(i,n) P[arr[i]]=i+1;
return;
}
vector<int> v;
REP(i,n) v.pb(i);
srt(v,1,N,P);
}
Compilation message
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
68 | }
| ^
koala.cpp: In function 'bool cmp(int, int)':
koala.cpp:109:1: warning: control reaches end of non-void function [-Wreturn-type]
109 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
316 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
320 KB |
Output is correct |
2 |
Correct |
12 ms |
208 KB |
Output is correct |
3 |
Correct |
12 ms |
316 KB |
Output is correct |
4 |
Correct |
11 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
344 KB |
Output is correct |
2 |
Correct |
57 ms |
324 KB |
Output is correct |
3 |
Correct |
46 ms |
468 KB |
Output is correct |
4 |
Correct |
51 ms |
332 KB |
Output is correct |
5 |
Correct |
47 ms |
328 KB |
Output is correct |
6 |
Correct |
48 ms |
328 KB |
Output is correct |
7 |
Correct |
52 ms |
328 KB |
Output is correct |
8 |
Correct |
48 ms |
336 KB |
Output is correct |
9 |
Correct |
52 ms |
328 KB |
Output is correct |
10 |
Correct |
47 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
316 KB |
Output is correct |
2 |
Correct |
28 ms |
316 KB |
Output is correct |
3 |
Correct |
28 ms |
208 KB |
Output is correct |
4 |
Correct |
27 ms |
320 KB |
Output is correct |
5 |
Correct |
27 ms |
208 KB |
Output is correct |
6 |
Correct |
27 ms |
316 KB |
Output is correct |
7 |
Correct |
27 ms |
208 KB |
Output is correct |
8 |
Correct |
27 ms |
208 KB |
Output is correct |
9 |
Correct |
27 ms |
312 KB |
Output is correct |
10 |
Correct |
27 ms |
208 KB |
Output is correct |
11 |
Correct |
28 ms |
208 KB |
Output is correct |
12 |
Correct |
15 ms |
208 KB |
Output is correct |
13 |
Correct |
27 ms |
316 KB |
Output is correct |
14 |
Correct |
26 ms |
208 KB |
Output is correct |
15 |
Correct |
24 ms |
208 KB |
Output is correct |
16 |
Correct |
24 ms |
316 KB |
Output is correct |
17 |
Correct |
24 ms |
300 KB |
Output is correct |
18 |
Correct |
25 ms |
208 KB |
Output is correct |
19 |
Correct |
25 ms |
208 KB |
Output is correct |
20 |
Correct |
25 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
3 ms |
208 KB |
Output is correct |
12 |
Correct |
3 ms |
208 KB |
Output is correct |
13 |
Correct |
3 ms |
208 KB |
Output is correct |
14 |
Correct |
3 ms |
208 KB |
Output is correct |
15 |
Correct |
3 ms |
208 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
3 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
3 ms |
208 KB |
Output is correct |
20 |
Correct |
3 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
208 KB |
Output is correct |
24 |
Correct |
3 ms |
208 KB |
Output is correct |
25 |
Correct |
3 ms |
208 KB |
Output is correct |
26 |
Correct |
3 ms |
208 KB |
Output is correct |
27 |
Correct |
3 ms |
208 KB |
Output is correct |
28 |
Correct |
3 ms |
208 KB |
Output is correct |
29 |
Correct |
3 ms |
208 KB |
Output is correct |
30 |
Correct |
3 ms |
208 KB |
Output is correct |
31 |
Correct |
3 ms |
208 KB |
Output is correct |
32 |
Correct |
3 ms |
208 KB |
Output is correct |
33 |
Correct |
3 ms |
208 KB |
Output is correct |
34 |
Correct |
3 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
208 KB |
Output is correct |
36 |
Correct |
3 ms |
208 KB |
Output is correct |
37 |
Correct |
3 ms |
208 KB |
Output is correct |
38 |
Correct |
3 ms |
208 KB |
Output is correct |
39 |
Correct |
3 ms |
208 KB |
Output is correct |
40 |
Correct |
3 ms |
208 KB |
Output is correct |