Submission #1296178

#TimeUsernameProblemLanguageResultExecution timeMemory
1296178eri16Counting Mushrooms (IOI20_mushrooms)C++20
Compilation error
0 ms0 KiB
int count_mushrooms(int n){
    
    vector <int> A;
    vector <int> B;
    
    int ans=1;
    int cur=150;
        
    A.push_back(0);
    
    for (int i=1; i<3 && i<n; i++){
        vector <int> test;
        test.push_back(0);
        test.push_back(i);
        if (use_machine(test)==0){
            A.push_back(i);
            ans++;
        }
        else{
            B.push_back(i);
        }
    }
    
    vector <int> c;
    
    if (A.size()>B.size()){c=A;}
    else{c=B;}
    
    for (int i=3; i<n; i=i+2){
        vector <int> test;
        test.push_back(i);
        test.push_back(c[0]);
        if (i+1<n){test.push_back(i+1);test.push_back(c[1]);}
        
        int tmans=use_machine(test);
        
        if (c[0]==0){
            if (tmans==0){A.push_back(i);ans++;
                if (i+1<n){A.push_back(i+1);ans++;}
            }
            if (tmans==1){
                B.push_back(i);
                if (i+1<n){A.push_back(i+1);ans++;}
            }
            if (tmans==2){
                A.push_back(i);ans++;
                if (i+1<n){A.push_back(i+1);}
            }            
            if (tmans==3){
                B.push_back(i);
                if (i+1<n){B.push_back(i+1);}                
            }
        }
        else{
            if (tmans==3){A.push_back(i);ans++;
                if (i+1<n){A.push_back(i+1);ans++;}
            }
            if (tmans==2){
                B.push_back(i);
                if (i+1<n){A.push_back(i+1);ans++;}
            }
            if (tmans==1){
                A.push_back(i);ans++;
                if (i+1<n){A.push_back(i+1);}
            }            
            if (tmans==0){
                B.push_back(i);
                if (i+1<n){B.push_back(i+1);}                
            }
        }
    }    
    return ans;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:3:5: error: 'vector' was not declared in this scope
    3 |     vector <int> A;
      |     ^~~~~~
mushrooms.cpp:3:13: error: expected primary-expression before 'int'
    3 |     vector <int> A;
      |             ^~~
mushrooms.cpp:4:13: error: expected primary-expression before 'int'
    4 |     vector <int> B;
      |             ^~~
mushrooms.cpp:9:5: error: 'A' was not declared in this scope
    9 |     A.push_back(0);
      |     ^
mushrooms.cpp:12:17: error: expected primary-expression before 'int'
   12 |         vector <int> test;
      |                 ^~~
mushrooms.cpp:13:9: error: 'test' was not declared in this scope
   13 |         test.push_back(0);
      |         ^~~~
mushrooms.cpp:15:13: error: 'use_machine' was not declared in this scope
   15 |         if (use_machine(test)==0){
      |             ^~~~~~~~~~~
mushrooms.cpp:20:13: error: 'B' was not declared in this scope
   20 |             B.push_back(i);
      |             ^
mushrooms.cpp:24:13: error: expected primary-expression before 'int'
   24 |     vector <int> c;
      |             ^~~
mushrooms.cpp:26:18: error: 'B' was not declared in this scope
   26 |     if (A.size()>B.size()){c=A;}
      |                  ^
mushrooms.cpp:26:28: error: 'c' was not declared in this scope
   26 |     if (A.size()>B.size()){c=A;}
      |                            ^
mushrooms.cpp:27:10: error: 'c' was not declared in this scope
   27 |     else{c=B;}
      |          ^
mushrooms.cpp:30:17: error: expected primary-expression before 'int'
   30 |         vector <int> test;
      |                 ^~~
mushrooms.cpp:31:9: error: 'test' was not declared in this scope
   31 |         test.push_back(i);
      |         ^~~~
mushrooms.cpp:32:24: error: 'c' was not declared in this scope
   32 |         test.push_back(c[0]);
      |                        ^
mushrooms.cpp:35:19: error: 'use_machine' was not declared in this scope
   35 |         int tmans=use_machine(test);
      |                   ^~~~~~~~~~~
mushrooms.cpp:42:17: error: 'B' was not declared in this scope
   42 |                 B.push_back(i);
      |                 ^
mushrooms.cpp:50:17: error: 'B' was not declared in this scope
   50 |                 B.push_back(i);
      |                 ^
mushrooms.cpp:59:17: error: 'B' was not declared in this scope
   59 |                 B.push_back(i);
      |                 ^
mushrooms.cpp:67:17: error: 'B' was not declared in this scope
   67 |                 B.push_back(i);
      |                 ^