Submission #402748

# Submission time Handle Problem Language Result Execution time Memory
402748 2021-05-12T10:22:44 Z teehandsome Koala Game (APIO17_koala) C++11
29 / 100
102 ms 428 KB
#include "koala.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,w;

int minValue(int N, int W) {
    n=N,w=W;
    int a[n],b[n];
    memset(a,0,sizeof(a));
    a[0]=w-n+1;

    playRound(a,b);
    for(int i=0;i<n;i++) {
        if(b[i]<=a[i]) return i;
    }
}

int solve(vector<bool> flag,int n2,int c,int n) {
//    debug(n2);
    int a[n]; memset(a,0,sizeof(a));
    if(n2==1) {
        for(int i=0;i<n;i++) {
            if(!flag[i]) return i;
        }
    }
    else if(n2==2) {
        c=10;
//        int a[n];
//        for(int i=0;i<n;i++) {
//            if(flag[i]) a[i]=0;
//            else a[i]=49
//        }
    }
    for(int i=0;i<n;i++) {
        if(flag[i]) continue;
        a[i]=c;
    }
    int b[n];
//    cout<<"==="<<endl;
//    for(int i=0;i<n;i++) {
//        cout<<a[i]<<" ";
//    }
//    cout<<endl;
    playRound(a,b);
    int cnt=0;
    for(int i=0;i<n;i++) {
        if(b[i]>a[i] and a[i]!=0) {
            flag[i]=false; cnt++;
        }
        else flag[i]=true;
    }
    return solve(flag,cnt,c*2,n);
}

int maxValue(int N, int W) {
    n=N,w=W;
    vector<bool> flag(n,false);
    return solve(flag,n,1,n);
}

int greaterValue(int N, int W) {
    n=N,w=W; int mn=minValue(N,W);
    if(mn==0) return 1;
    if(mn==1) return 0;
    int a[n]; memset(a,0,sizeof(a));
    a[0]=a[1]=1;
    int b[n];
    int l=1,r=10;
    while(l<=r) {
        int mid=(l+r)/2;
        a[0]=a[1]=mid;
        playRound(a,b);
        if(b[0]>a[0] and b[1]>a[1]) {
            l=mid+1;
        }
        else if(b[0]<=a[0] and b[1]<=a[1]) {
            r=mid-1;
        }
        else {
            if(b[0]>a[0]) return 0;
            return 1;
        }
    }
    assert(false);
}

void allValues(int N, int W, int *P) {
    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:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 5 ms 200 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 21 ms 200 KB Output is partially correct
2 Partially correct 19 ms 200 KB Output is partially correct
3 Partially correct 19 ms 312 KB Output is partially correct
4 Partially correct 22 ms 308 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 316 KB Output is correct
2 Correct 94 ms 324 KB Output is correct
3 Correct 95 ms 312 KB Output is correct
4 Correct 94 ms 312 KB Output is correct
5 Correct 93 ms 312 KB Output is correct
6 Correct 93 ms 200 KB Output is correct
7 Correct 94 ms 316 KB Output is correct
8 Correct 96 ms 320 KB Output is correct
9 Correct 102 ms 320 KB Output is correct
10 Correct 94 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -