제출 #759908

#제출 시각아이디문제언어결과실행 시간메모리
759908raysh07Counting Mushrooms (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;

int count_mushrooms(int n) {
// 	std::vector<int> m;
// 	for (int i = 0; i < n; i++)
// 		m.push_back(i);
// 	int c1 = use_machine(m);
// 	m = {0, 1};
// 	int c2 = use_machine(m);
// 	return c1+c2;

    vector <int> a, b;
    a.push_back(0)
    const int N = min(200, n);
    
    for (int i = 1; i < N; i++){
        vector <int> m = {0, i};
        int c = use_machine(m);
        
        if (c == 0) a.push_back(i);
        else b.push_back(i);
    }
    
    if (N == n) return a.size();
    int ans = 0;
    
    while (N < n){
        int x = min(N + 99, n - 1);
        int add = x - N + 1;
        
        if (a.size() >= 100){
            vector <int> m;
            for (int i = 0; i < add; i++){
                m.push_back(a[i]);
                m.push_back(N + i);
            }
            
            int c = use_machine(m);
            //every B will add 2, except for 1 
            c++;
            int bb = c/2;
            int aa = add - bb;
            ans += aa;
        } else {
            assert(b.size() >= 100);
            vector <int> m;
            for (int i = 0; i < add; i++){
                m.push_back(b[i]);
                m.push_back(N + i);
            }
            
            int c = use_machine(m) + 1;
            ans += c/2;
        }
        
        N = x + 1;
    }
    
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:15:19: error: expected ';' before 'const'
   15 |     a.push_back(0)
      |                   ^
      |                   ;
   16 |     const int N = min(200, n);
      |     ~~~~~          
mushrooms.cpp:18:25: error: 'N' was not declared in this scope
   18 |     for (int i = 1; i < N; i++){
      |                         ^
mushrooms.cpp:26:9: error: 'N' was not declared in this scope
   26 |     if (N == n) return a.size();
      |         ^
mushrooms.cpp:29:12: error: 'N' was not declared in this scope
   29 |     while (N < n){
      |            ^