Submission #544993

# Submission time Handle Problem Language Result Execution time Memory
544993 2022-04-03T09:48:59 Z zaneyu Koala Game (APIO17_koala) C++14
74 / 100
69 ms 340 KB
#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];
}
//a less than b
int n,w;
/*
bool cmp(int a,int b){
    REP(i,n) play[i]=0;
    play[a]=1,play[b]=1;
    playRound(play,ans);
    if(ans[a] and ans[b]){
        int l=2,r=10;
        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;
            else{
                if(ans[a]){
                    return 0;
                }
                if(ans[b]){
                    return 1;
                }
            }
        }
        play[a]=l,play[b]=l;
        playRound(play,ans);
        if(ans[a]) return 0;
        return 1;
    }
    else{
        if(ans[a]) return 0;
        return 1;
    }
}*/
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=10;
    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;
        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(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;
    REP(i,n) arr[i]=i;
    srt(0,n-1);
    REP(i,n) P[arr[i]]=i+1;
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}

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:140:1: warning: control reaches end of non-void function [-Wreturn-type]
  140 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 312 KB Output is correct
2 Correct 13 ms 320 KB Output is correct
3 Correct 15 ms 320 KB Output is correct
4 Correct 13 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 336 KB Output is correct
2 Correct 62 ms 328 KB Output is correct
3 Correct 53 ms 340 KB Output is correct
4 Correct 51 ms 328 KB Output is correct
5 Correct 62 ms 336 KB Output is correct
6 Correct 68 ms 332 KB Output is correct
7 Correct 61 ms 328 KB Output is correct
8 Correct 59 ms 332 KB Output is correct
9 Correct 69 ms 328 KB Output is correct
10 Correct 56 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 316 KB Output is correct
2 Correct 34 ms 296 KB Output is correct
3 Correct 35 ms 300 KB Output is correct
4 Correct 32 ms 208 KB Output is correct
5 Correct 31 ms 316 KB Output is correct
6 Correct 31 ms 208 KB Output is correct
7 Correct 42 ms 208 KB Output is correct
8 Correct 34 ms 296 KB Output is correct
9 Correct 31 ms 292 KB Output is correct
10 Correct 31 ms 296 KB Output is correct
11 Correct 35 ms 316 KB Output is correct
12 Correct 19 ms 312 KB Output is correct
13 Correct 34 ms 208 KB Output is correct
14 Correct 36 ms 300 KB Output is correct
15 Correct 28 ms 208 KB Output is correct
16 Correct 33 ms 296 KB Output is correct
17 Correct 27 ms 316 KB Output is correct
18 Correct 35 ms 292 KB Output is correct
19 Correct 33 ms 208 KB Output is correct
20 Correct 31 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 25 ms 208 KB Output is partially correct
2 Partially correct 30 ms 208 KB Output is partially correct
3 Partially correct 33 ms 208 KB Output is partially correct
4 Partially correct 29 ms 296 KB Output is partially correct
5 Partially correct 27 ms 236 KB Output is partially correct
6 Partially correct 28 ms 300 KB Output is partially correct
7 Partially correct 25 ms 208 KB Output is partially correct
8 Partially correct 25 ms 208 KB Output is partially correct
9 Partially correct 28 ms 316 KB Output is partially correct
10 Partially correct 25 ms 304 KB Output is partially correct
11 Partially correct 25 ms 208 KB Output is partially correct
12 Partially correct 16 ms 320 KB Output is partially correct
13 Partially correct 34 ms 292 KB Output is partially correct
14 Partially correct 25 ms 208 KB Output is partially correct
15 Partially correct 25 ms 208 KB Output is partially correct
16 Partially correct 28 ms 208 KB Output is partially correct
17 Partially correct 26 ms 312 KB Output is partially correct
18 Partially correct 33 ms 208 KB Output is partially correct
19 Partially correct 26 ms 316 KB Output is partially correct
20 Partially correct 25 ms 316 KB Output is partially correct
21 Partially correct 26 ms 208 KB Output is partially correct
22 Partially correct 25 ms 312 KB Output is partially correct
23 Partially correct 22 ms 312 KB Output is partially correct
24 Partially correct 25 ms 316 KB Output is partially correct
25 Partially correct 24 ms 312 KB Output is partially correct
26 Partially correct 25 ms 208 KB Output is partially correct
27 Partially correct 24 ms 316 KB Output is partially correct
28 Partially correct 26 ms 296 KB Output is partially correct
29 Partially correct 26 ms 208 KB Output is partially correct
30 Partially correct 24 ms 300 KB Output is partially correct
31 Partially correct 25 ms 208 KB Output is partially correct
32 Partially correct 34 ms 208 KB Output is partially correct
33 Partially correct 28 ms 324 KB Output is partially correct
34 Partially correct 23 ms 316 KB Output is partially correct
35 Partially correct 25 ms 208 KB Output is partially correct
36 Partially correct 24 ms 316 KB Output is partially correct
37 Partially correct 22 ms 316 KB Output is partially correct
38 Partially correct 26 ms 320 KB Output is partially correct
39 Partially correct 24 ms 320 KB Output is partially correct
40 Partially correct 32 ms 208 KB Output is partially correct