제출 #1302749

#제출 시각아이디문제언어결과실행 시간메모리
1302749sano버섯 세기 (IOI20_mushrooms)C++20
컴파일 에러
0 ms0 KiB
#include "mushrooms.h"
#include <set>
#define vec vector
#define For(i, n) for(int i = 0; i < n; i++)
using namespace std;

int count_mushrooms(int n) {
	vec<int> odp(n, 0);
	vec<int> m;
	m.push_back(0);
	vec<int> p(2, 0);
	vec<int> m;
	p[0]++;
	m.push_back(0);
	m.push_back(1);
	int x = use_machine(m);
	odp[1] = x;
	p[odp[1]]++;
	m.clear();
	m.push_back(1);
	m.push_back(2);
	x = use_machine(m);
	if(x == 1) odp[2] = 1 - odp[1];
	else odp[2] = odp[1];
	p[odp[2]]++;
	int typ = 0;
	if(p[1] >= 2){
		typ = 1;
	}
	m.clear();
	For(i, 3){
		if(odp[i] == typ && m.size() < 2) m.push_back(i);
	}
	for (int i = 3; i < n; i+=2) {
		vec<int> nm;
		nm.push_back(m[0]);
		nm.push_back(i);
		nm.push_back(m[1]);
		nm.push_back(i+1);
		x = use_machine(nm);
		if((x % 2) == 1){
			odp[i+1] = 1 - typ;
		}
		else{
			odp[i+1] = typ;
		}
		if(x > 1){
			odp[i] = 1 - typ;
		}
		else{
			odp[i] = typ;
		}
	}
	For(i, n){
		p[odp[i]]++;
	}
	return p[0];
}

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:12:18: error: redeclaration of 'std::vector<int> m'
   12 |         vec<int> m;
      |                  ^
mushrooms.cpp:9:18: note: 'std::vector<int> m' previously declared here
    9 |         vec<int> m;
      |                  ^