Submission #1362838

#TimeUsernameProblemLanguageResultExecution timeMemory
1362838jumpKoala Game (APIO17_koala)C++20
Compilation error
0 ms0 KiB
#include "koala.h"
#include <bits/stdc++.h>
int parr[110];
int res[110];
int NG,NW,PH;
int call=1;
int theres=13;
void play(){
    while(call>theres);
    std::cout << "in";
    for(int i=0;i<NG;i++)std::cout << parr[i];
    std::cout << '\n';
    //std::cout << call;
    playRound(parr,res);
    std::cout << "out";
    for(int i=0;i<NW;i++)std::cout << res[i];
    std::cout << '\n';
    ++call;
    //std::cin >> PH;
}
int minValue(int N, int W) {
    NG=N,NW=W;
    parr[0]=1;
    play();
    if(res[0]<2)return 0;
    for(int i=1;i<N;i++){
        if(res[i]==0)return i;
    }
    return 0;
}
/*
1 1   
10 10
2 1 3 4 5 6 7 8 9 10
*/
/*
1 1   
10 10
10 3 2 4 5 6 7 8 9 1
*/
int maxValue(int N, int W) {
    NG=N,NW=W;
    for(int i=0;i<N;i++){
        parr[i]=0;
        res[i]=0;
    }
    bool notans[105];
    for(int i=0;i<N;i++){
        notans[i]=false;
    }
    int cnt=N;
    int t=0;
    std::vector<int> precalcN={1,2,4,11,14,14,14,14,14,14,14};
    while(cnt>1){
        //std::cout << cnt << ' ';
        for(int i=0;i<N;i++){
            if(notans[i])parr[i]=0;
            else parr[i]=precalcN[t];
        }
        play();
        for(int i=0;i<N;i++){
            if(notans[i])continue;
            if(parr[i]>=res[i])cnt-=1,notans[i]=true;
        }
        t++;
        //std::cout << cnt << '|';
    }
    for(int i=0;i<N;i++)if(!notans[i])return i;
    return 0;
}
/*
2 1   
10 10
10 3 2 4 5 6 7 8 9 1
*/
/*
2 1   
100 100
21 10 39 58 46 91 67 40 99 53 71 89 48 78 16 38 81 28 2 34 45 8 88 54 55 42 11 93 74 84 32 20 56 44 17 29 92 96 26 30 69 57 97 5 85 27 95 35 98 24 25 63 15 41 49 13 47 83 31 72 6 37 22 75 61 59 43 94 52 65 73 51 7 70 19 87 64 36 3 77 86 62 33 79 18 76 60 100 82 9 1 23 4 14 80 66 68 12 50 90
*/
/*
2 1   
100 100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
*/

int greaterValue(int N, int W) {
    NG=N,NW=W;
    for(int i=0;i<N;i++){
        parr[i]=0;
        res[i]=0;
    }
    parr[0]=5,parr[1]=5;
    play();
    bool col0 = res[0]>parr[0];
    bool col1 = res[1]>parr[1];
    if(col0&&!col1)return 0
    else if(!col0&&col1)return 1;
    else if(col0&&col1){
        parr[0]=8,parr[1]=8;
        play();
        col0 = res[0]>parr[0];
        col1 = res[1]>parr[1];
        if(col0&&!col1)return 0
        else if(!col0&&col1)return 1;
    }
    else{
        parr[0]=2,parr[1]=2;
        play();
        col0 = res[0]>parr[0];
        col1 = res[1]>parr[1];
        if(col0&&!col1)return 0
        else if(!col0&&col1)return 1;
        else if(col0&&col1){
            parr[0]=1,parr[1]=1;
            play();
            col0 = res[0]>parr[0];
            col1 = res[1]>parr[1];
            if(col0&&!col1)return 0
            else if(!col0&&col1)return 1;
        }
        else{
            parr[0]=3,parr[1]=3;
            play();
            col0 = res[0]>parr[0];
            col1 = res[1]>parr[1];
            if(col0&&!col1)return 0
            else if(!col0&&col1)return 1;
        }
    }
    return 0;
}
/*
3 1   
100 100
2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
*/
void allValues(int N, int W, int *P) {
    NG=N,NW=W;
    if (W == 2*N) {
        for(int i=0;i<N;i++)P[i]=-1;
        for(int l=0;l<N-1;l++){
            //std::cout << '-' << l << ':' << '\n';
            for(int i=0;i<N;i++){
                parr[i]=0;
                res[i]=0;
            }
            bool notRes[105];
            int cnt=N;
            for(int i=0;i<N;i++){
                notRes[i]=false;
                if(P[i]!=-1)cnt-=1,notRes[i]=true;
            }
            int t=0;
            while(cnt>1){
                for(int i=0;i<N;i++){
                    if(notRes[i])parr[i]=0;
                    //if(P[i]!=-1&&l!=0)parr[i]=100/(l);
                    else parr[i]=(W/(cnt));
                }
                //std::cout << '|' << cnt << "->";
                play();
                for(int i=0;i<N;i++){
                    if(notRes[i])continue;
                    if(parr[i]>=res[i])cnt-=1,notRes[i]=true;
                }
                t++;
            }
            bool found=false;
            for(int i=0;i<N;i++){
                if(!notRes[i]){
                    P[i]=N-l;
                    found=true;
                    //std::cout << i << "->" << N-l << '\n';
                    break;
                }
            }
            if(!found){
                std::cout << l << ' ';
                std::cin >> PH;
            }
            //std::cin >> PH;
        }
        for(int i=0;i<N;i++)if(P[i]==-1)P[i]=1;
        return;
    } else {
    }
}
/*
4 1   
100 200
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
*/

Compilation message (stderr)

koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:97:28: error: expected ';' before 'else'
   97 |     if(col0&&!col1)return 0
      |                            ^
      |                            ;
   98 |     else if(!col0&&col1)return 1;
      |     ~~~~                    
koala.cpp:104:32: error: expected ';' before 'else'
  104 |         if(col0&&!col1)return 0
      |                                ^
      |                                ;
  105 |         else if(!col0&&col1)return 1;
      |         ~~~~                    
koala.cpp:112:32: error: expected ';' before 'else'
  112 |         if(col0&&!col1)return 0
      |                                ^
      |                                ;
  113 |         else if(!col0&&col1)return 1;
      |         ~~~~                    
koala.cpp:119:36: error: expected ';' before 'else'
  119 |             if(col0&&!col1)return 0
      |                                    ^
      |                                    ;
  120 |             else if(!col0&&col1)return 1;
      |             ~~~~                    
koala.cpp:127:36: error: expected ';' before 'else'
  127 |             if(col0&&!col1)return 0
      |                                    ^
      |                                    ;
  128 |             else if(!col0&&col1)return 1;
      |             ~~~~