Submission #1103993

# Submission time Handle Problem Language Result Execution time Memory
1103993 2024-10-22T14:37:27 Z vjudge1 Counting Mushrooms (IOI20_mushrooms) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;

int count_mushrooms(int n){
    vector<int> w,b;
    char c;
    int s,ans=0;
    w.push_back(0);
    if(use_machine([0,1])){
        b.push_back(1);
        if(use_machine([0,2])){
            b.push_back(2);
            c='b';
        } else {
            w.push_back(2);
            c='w';
        }
        s=3;
    } else {
        w.push_back(1);
        c='w';
        s=2;
    }
    int d=min(100,(n-s)/2);

    while(d--){
        if(c=='w'){
            int tmp=use_machine([w[0],s,w[1],s+1]);
            if(tmp%2){
                b.push_back(s+1);
            } else {
                w.push_back(s+1);
            }
            if(tmp/2){
                b.push_back(s);
            } else {
                w.push_back(s);
            }
            s+=2;
        } else {
            int tmp=use_machine([b[0],s,b[1],s+1]);
            if(tmp%2){
                w.push_back(s+1);
            } else {
                b.push_back(s+1);
            }
            if(tmp/2){
                w.push_back(s);
            } else {
                b.push_back(s);
            }
            s+=2;
        }
    }
    ans=w.size();
    int sz=max(b.size(),w.size());
    while(n-s>=sz){
        int tmp[2*sz];
        if(w.size()>b.size()){
            for(int i=0;i<sz;i++,s++){
                tmp[i*2]=w[i];
                tmp[i*2+1]=s;
            }
            int t=use_machine(tmp);
            if(t%2)b.push_back(s-1);
            else w.push_back(s-1);
            ans+=sz-(t+1)/2;
        } else {
            for(int i=0;i<sz;i++,s++){
                tmp[i*2]=b[i];
                tmp[i*2+1]=s;
            }
            int t=use_machine(tmp);
            if(t%2)w.push_back(s-1);
            else b.push_back(s-1);
            ans+=(t+1)/2;
        }
        sz=max(b.size(),w.size());
    }
    int tmp[(n-s)*2];
    if(w.size()>b.size()){
        for(int i=0;s<n;i++,s++){
            tmp[i*2]=w[i];
            tmp[i*2+1]=s;
        }
        int t=use_machine(tmp);
        if(t%2)b.push_back(s-1);
        else w.push_back(s-1);
        ans+=sz-(t+1)/2;
    } else {
        for(int i=0;s<n;i++,s++){
            tmp[i*2]=b[i];
            tmp[i*2+1]=s;
        }
        int t=use_machine(tmp);
        if(t%2)w.push_back(s-1);
        else b.push_back(s-1);
        ans+=(t+1)/2;
    }
    return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:10:21: error: expected identifier before numeric constant
   10 |     if(use_machine([0,1])){
      |                     ^
mushrooms.cpp:10:22: error: expected ']' before ',' token
   10 |     if(use_machine([0,1])){
      |                      ^
      |                      ]
mushrooms.cpp: In lambda function:
mushrooms.cpp:10:22: error: expected '{' before ',' token
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:10:24: error: expected ')' before ']' token
   10 |     if(use_machine([0,1])){
      |                   ~    ^
      |                        )
mushrooms.cpp:10:24: error: expected ')' before ']' token
   10 |     if(use_machine([0,1])){
      |       ~                ^
      |                        )
mushrooms.cpp:10:24: error: expected primary-expression before ']' token
mushrooms.cpp:29:35: error: expected ',' before '[' token
   29 |             int tmp=use_machine([w[0],s,w[1],s+1]);
      |                                   ^
      |                                   ,
mushrooms.cpp:29:35: error: expected identifier before '[' token
mushrooms.cpp:29:38: error: expected ']' before ',' token
   29 |             int tmp=use_machine([w[0],s,w[1],s+1]);
      |                                      ^
      |                                      ]
mushrooms.cpp: In lambda function:
mushrooms.cpp:29:38: error: expected '{' before ',' token
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:29:49: error: expected ')' before ']' token
   29 |             int tmp=use_machine([w[0],s,w[1],s+1]);
      |                                ~                ^
      |                                                 )
mushrooms.cpp:42:35: error: expected ',' before '[' token
   42 |             int tmp=use_machine([b[0],s,b[1],s+1]);
      |                                   ^
      |                                   ,
mushrooms.cpp:42:35: error: expected identifier before '[' token
mushrooms.cpp:42:38: error: expected ']' before ',' token
   42 |             int tmp=use_machine([b[0],s,b[1],s+1]);
      |                                      ^
      |                                      ]
mushrooms.cpp: In lambda function:
mushrooms.cpp:42:38: error: expected '{' before ',' token
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:42:49: error: expected ')' before ']' token
   42 |             int tmp=use_machine([b[0],s,b[1],s+1]);
      |                                ~                ^
      |                                                 )
mushrooms.cpp:65:31: error: could not convert '(int*)(& tmp)' from 'int*' to 'std::vector<int>'
   65 |             int t=use_machine(tmp);
      |                               ^~~
      |                               |
      |                               int*
mushrooms.cpp:74:31: error: could not convert '(int*)(& tmp)' from 'int*' to 'std::vector<int>'
   74 |             int t=use_machine(tmp);
      |                               ^~~
      |                               |
      |                               int*
mushrooms.cpp:87:27: error: could not convert '(int*)(& tmp)' from 'int*' to 'std::vector<int>'
   87 |         int t=use_machine(tmp);
      |                           ^~~
      |                           |
      |                           int*
mushrooms.cpp:96:27: error: could not convert '(int*)(& tmp)' from 'int*' to 'std::vector<int>'
   96 |         int t=use_machine(tmp);
      |                           ^~~
      |                           |
      |                           int*