This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "koala.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i;
int minValue(int N, int W) {
int a[110],b[110];
for(i=0;i<N;i++)
a[i]=0;
a[0]=1;
playRound(a,b);
for(i=0;i<N;i++)
if(b[i]==0)
return i;
return 0;
}
int maxValue(int N, int W) {
ll VS,K;
int a[110],b[110];
vector<ll> v;
for(i=0;i<N;i++)
v.pb(i);
VS=N;
K=1;
while(VS>1)
{
vector<ll> vv;
for(i=0;i<N;i++)
a[i]=0;
K=W/VS;
for(i=0;i<VS;i++)
a[v[i]]=K;
playRound(a,b);
for(i=0;i<N;i++)
if(b[i]>K)
vv.pb(i);
v=vv;
VS=v.size();
}
return v[0];
}
ll L,R,C;
int greaterValue(int N, int W) {
int a[110],b[110];
for(i=0;i<N;i++)
a[i]=0;
L=1;
R=min(14,N/2);
while(L<=R)
{
C=(L+R)/2;
a[0]=C;
a[1]=C;
playRound(a,b);
//cout<<i<<" "<<b[0]<<" "<<b[1]<<"\n";
if(b[0]>b[1])return 0;
if(b[0]<b[1])return 1;
if(b[0]>C)L=C+1;
else R=C-1;
}
return 0;
}
bool gol (ll aa,ll bb,ll cc,ll dd)
{
if((cc-bb)>dd)
return 1;
while(1)
{
if(cc<=dd)return 0;
ll ii,H=0;
for(ii=bb;ii>=bb-dd;ii--)
H+=max(ii,0LL);
if(H<aa)return 1;
bb-=(dd+1);
cc-=(dd+1);
}
}
ll mc[110];
vector<ll> VC[110];
bool cmp(ll aa,ll bb)
{
return (VC[aa]>VC[bb]);
}
void allValues(int N, int W, int *P) {
if (W == 2*N) {
ll VS,K;
int a[110],b[110],sud[110];
for(i=0;i<N;i++)
sud[i]=0;
ll j;
for(j=N-1;j>=0;j--)
{
vector<ll> v;
for(i=0;i<N;i++)
if(!sud[i])
v.pb(i);
VS=j+1;
K=2;
while(VS>1)
{
vector<ll> vv;
for(i=0;i<N;i++)
a[i]=0;
K=W/VS;
for(i=0;i<VS;i++)
a[v[i]]=K;
playRound(a,b);
for(i=0;i<N;i++)
if(b[i]>K&&a[i]==K)
vv.pb(i);
v=vv;
VS=v.size();
}
sud[v[0]]=1;
P[v[0]]=j+1;
}
} else {
ll VS,K;
int a[110],b[110],sud[110];
for(i=0;i<N;i++)
sud[i]=0;
ll j,TTT=0;
vector<ll> v2;
for(j=N-1;j>=0;j--)
{
int TTT=0;
vector<ll> v;
for(i=0;i<N;i++)
if(!sud[i])
v.pb(i);
sort(v.begin(),v.end(),cmp);
VS=v.size();
while(VS>=1)
{
if(VC[v[VS-1]]!=VC[v[0]])
{
// cout<<"AA";
VS--;
v.pop_back();
}
else
break;
}
K=1;
v2.clear();
memset(mc,0,sizeof(mc));
while(VS>1)
{
vector<ll> vv;
for(i=0;i<N;i++)
a[i]=0;
K=1;
for(i=(W/VS);i>=0;i--)
if(gol(j+1,j+1-VS,(W-(N-(j+1))),i))
{
K=i;
break;
}
for(i=0;i<VS;i++)
a[v[i]]=K;
TTT++;
playRound(a,b);
for(i=0;i<N;i++)
if(b[i]>K&&a[i]==K)
{
vv.pb(i);
mc[i]=TTT;
}
v=vv;
VS=v.size();
}
for(i=0;i<N;i++)
VC[i].pb(mc[i]);
//cout<<j<<" "<<TTT<<"\n";
sud[v[0]]=1;
P[v[0]]=j+1;
}
// cout<<TTT<<"\n";
}
}
Compilation message (stderr)
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:128:14: warning: unused variable 'TTT' [-Wunused-variable]
ll j,TTT=0;
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |