Submission #544980

# Submission time Handle Problem Language Result Execution time Memory
544980 2022-04-03T09:31:19 Z zaneyu Koala Game (APIO17_koala) C++14
19 / 100
89 ms 324 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;
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;
    }
}
int greaterValue(int N, int W) {
    n=N;
    return (int)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;
    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 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 4 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 12 ms 208 KB Output is correct
2 Correct 11 ms 324 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 11 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -