Submission #1030302

# Submission time Handle Problem Language Result Execution time Memory
1030302 2024-07-22T02:25:54 Z vjudge1 Koala Game (APIO17_koala) C++17
64 / 100
57 ms 600 KB
#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(243987);
int you[100],cnt;
int minValue(int N, int W) {
    int me[100]{1};
    playRound(me,you),cnt++;
    for(int i=0;i<N;i++)
        if(you[i]==0)
            return i;
    return 0;
}

int maxValue(int N, int W) {
    int me[100];
    vector<int>theposs(N);
    iota(theposs.begin(),theposs.end(),0);
    while(theposs.size()>1){
        memset(me,0,sizeof me);
        for(auto i:theposs)
            me[i]=W/theposs.size();
        playRound(me,you),cnt++;
        vector<int>theposs2;
        for(auto i:theposs)
            if(you[i])theposs2.push_back(i);
        theposs=theposs2;
    }
    return theposs[0];
}
int greaterValue(int N, int W) {
    int me[100]{1,1};
    int L=1,R=min(W/2,8);
    while(L<=R){
        int mid=L+R>>1;
        me[0]=mid;
        me[1]=mid;
        playRound(me,you),cnt++;
        if(you[0]-you[1])
            return cerr<<mid,!you[0];
        if(you[0])
            L=mid+1;
        else R=mid-1;
    }
    return 0;
}
int lst[101];
int smal[101];
int greaterValue2(int A,int B) {
    if(smal[A]^smal[B])
        return smal[A];
    if(lst[A]-lst[B])
        return lst[A]<lst[B];
    int me[100]{};
    me[A]=lst[A];me[B]=lst[B];
    if(cnt==700)assert(0);
    playRound(me,you),cnt++;
    return !you[A];
}

void allValues(int N, int W, int *P) {  
    vector<int>v(N);
    iota(v.begin(),v.end(),0);
    for(int i=0;i<N;i++){
        if(i==1000) {lst[i]=1e9;continue;}
        int l=1,r=15;
        while(l<=r){
            int mid=l+r+1>>1;
            int me[100]{};
            me[i]=mid;
            if(cnt==700)assert(0);
            playRound(me,you),cnt++;
            if(you[i])
                lst[i]=mid,l=mid+1;
            else r=mid-1;
        }
    }
    stable_sort(v.begin(),v.end(),[](int a,int b){
        return !greaterValue2(a,b);
    });
    for(int i=0;i<N;i++)
        P[v[i]]=N-i;
}

Compilation message

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:35:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |         int mid=L+R>>1;
      |                 ~^~
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:68:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   68 |             int mid=l+r+1>>1;
      |                     ~~~^~
koala.cpp:65:27: warning: array subscript 1000 is above array bounds of 'int [101]' [-Warray-bounds]
   65 |         if(i==1000) {lst[i]=1e9;continue;}
      |                      ~~~~~^
koala.cpp:47:5: note: while referencing 'lst'
   47 | int lst[101];
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 9 ms 456 KB Output is correct
4 Correct 9 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 49 ms 344 KB Output is partially correct
2 Partially correct 57 ms 468 KB Output is partially correct
3 Partially correct 57 ms 600 KB Output is partially correct
4 Partially correct 47 ms 344 KB Output is partially correct
5 Partially correct 48 ms 344 KB Output is partially correct
6 Partially correct 48 ms 344 KB Output is partially correct
7 Partially correct 54 ms 344 KB Output is partially correct
8 Partially correct 49 ms 344 KB Output is partially correct
9 Partially correct 53 ms 344 KB Output is partially correct
10 Partially correct 48 ms 476 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 344 KB Output is correct
2 Incorrect 31 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 13 ms 344 KB Output is partially correct
2 Partially correct 14 ms 456 KB Output is partially correct
3 Partially correct 14 ms 460 KB Output is partially correct
4 Partially correct 14 ms 344 KB Output is partially correct
5 Partially correct 14 ms 340 KB Output is partially correct
6 Partially correct 14 ms 344 KB Output is partially correct
7 Partially correct 14 ms 348 KB Output is partially correct
8 Partially correct 13 ms 344 KB Output is partially correct
9 Partially correct 14 ms 448 KB Output is partially correct
10 Partially correct 13 ms 344 KB Output is partially correct
11 Partially correct 14 ms 460 KB Output is partially correct
12 Partially correct 12 ms 452 KB Output is partially correct
13 Partially correct 13 ms 452 KB Output is partially correct
14 Partially correct 16 ms 344 KB Output is partially correct
15 Partially correct 15 ms 344 KB Output is partially correct
16 Partially correct 15 ms 344 KB Output is partially correct
17 Partially correct 14 ms 344 KB Output is partially correct
18 Partially correct 14 ms 344 KB Output is partially correct
19 Partially correct 14 ms 344 KB Output is partially correct
20 Partially correct 14 ms 344 KB Output is partially correct
21 Partially correct 13 ms 408 KB Output is partially correct
22 Partially correct 16 ms 344 KB Output is partially correct
23 Partially correct 13 ms 460 KB Output is partially correct
24 Partially correct 14 ms 344 KB Output is partially correct
25 Partially correct 13 ms 452 KB Output is partially correct
26 Partially correct 14 ms 344 KB Output is partially correct
27 Partially correct 16 ms 460 KB Output is partially correct
28 Partially correct 14 ms 344 KB Output is partially correct
29 Partially correct 14 ms 460 KB Output is partially correct
30 Partially correct 14 ms 344 KB Output is partially correct
31 Partially correct 13 ms 460 KB Output is partially correct
32 Partially correct 14 ms 344 KB Output is partially correct
33 Partially correct 13 ms 456 KB Output is partially correct
34 Partially correct 14 ms 344 KB Output is partially correct
35 Partially correct 14 ms 456 KB Output is partially correct
36 Partially correct 14 ms 344 KB Output is partially correct
37 Partially correct 14 ms 344 KB Output is partially correct
38 Partially correct 15 ms 344 KB Output is partially correct
39 Partially correct 14 ms 344 KB Output is partially correct
40 Partially correct 13 ms 344 KB Output is partially correct