Submission #544985

# Submission time Handle Problem Language Result Execution time Memory
544985 2022-04-03T09:35:31 Z zaneyu Koala Game (APIO17_koala) C++14
55 / 100
80 ms 432 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=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;
            else{
                if(ans[a]){
                    return 0;
                }
                if(ans[b]){
                    return 1;
                }
                r=mid-1;
            }
        }
        assert(false);
    }
    else{
        if(ans[a]) return 0;
        return 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;
    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 3 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 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 320 KB Output is correct
2 Correct 12 ms 208 KB Output is correct
3 Correct 13 ms 208 KB Output is correct
4 Correct 12 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 79 ms 328 KB Output is partially correct
2 Partially correct 80 ms 432 KB Output is partially correct
3 Partially correct 73 ms 320 KB Output is partially correct
4 Partially correct 79 ms 320 KB Output is partially correct
5 Partially correct 74 ms 328 KB Output is partially correct
6 Partially correct 74 ms 320 KB Output is partially correct
7 Partially correct 73 ms 336 KB Output is partially correct
8 Partially correct 74 ms 324 KB Output is partially correct
9 Partially correct 78 ms 328 KB Output is partially correct
10 Partially correct 79 ms 328 KB Output is partially correct
# 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 Partially correct 24 ms 208 KB Output is partially correct
2 Partially correct 37 ms 300 KB Output is partially correct
3 Partially correct 36 ms 208 KB Output is partially correct
4 Partially correct 36 ms 304 KB Output is partially correct
5 Partially correct 37 ms 208 KB Output is partially correct
6 Partially correct 37 ms 296 KB Output is partially correct
7 Partially correct 34 ms 296 KB Output is partially correct
8 Partially correct 35 ms 208 KB Output is partially correct
9 Partially correct 36 ms 300 KB Output is partially correct
10 Partially correct 37 ms 208 KB Output is partially correct
11 Partially correct 36 ms 208 KB Output is partially correct
12 Partially correct 20 ms 208 KB Output is partially correct
13 Partially correct 34 ms 208 KB Output is partially correct
14 Partially correct 35 ms 208 KB Output is partially correct
15 Partially correct 34 ms 208 KB Output is partially correct
16 Partially correct 44 ms 208 KB Output is partially correct
17 Partially correct 36 ms 208 KB Output is partially correct
18 Partially correct 34 ms 208 KB Output is partially correct
19 Partially correct 35 ms 208 KB Output is partially correct
20 Partially correct 34 ms 208 KB Output is partially correct
21 Partially correct 34 ms 208 KB Output is partially correct
22 Partially correct 36 ms 208 KB Output is partially correct
23 Partially correct 32 ms 304 KB Output is partially correct
24 Partially correct 35 ms 208 KB Output is partially correct
25 Partially correct 34 ms 208 KB Output is partially correct
26 Partially correct 37 ms 208 KB Output is partially correct
27 Partially correct 37 ms 328 KB Output is partially correct
28 Partially correct 35 ms 300 KB Output is partially correct
29 Partially correct 35 ms 208 KB Output is partially correct
30 Partially correct 34 ms 300 KB Output is partially correct
31 Partially correct 34 ms 296 KB Output is partially correct
32 Partially correct 35 ms 208 KB Output is partially correct
33 Partially correct 35 ms 208 KB Output is partially correct
34 Partially correct 32 ms 300 KB Output is partially correct
35 Partially correct 35 ms 208 KB Output is partially correct
36 Partially correct 34 ms 208 KB Output is partially correct
37 Partially correct 32 ms 208 KB Output is partially correct
38 Partially correct 31 ms 208 KB Output is partially correct
39 Partially correct 30 ms 316 KB Output is partially correct
40 Partially correct 32 ms 208 KB Output is partially correct