제출 #438671

#제출 시각아이디문제언어결과실행 시간메모리
438671Stickfish던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include "dungeons.h"
#include <vector>
using namespace std;

const int MAXN = 4e5 + 123;
int n;
int edg[MAXN][2];
int p[MAXN][2];

void init(int sn, vector<int> sv, vector<int> pv, vector<int> wv, vector<int> lv) {
	n = sn;
	for(int i = 0; i < n; ++i){
		edg[i][0] = wv[i];
		edg[i][1] = lv[i];
		p[i][0] = pv[i];
		p[i][1] = sv[i];
	}
	return;
}

long long simulate(int x, int z) {
	if(x >= n)
		return z;
	if(z >= p[x][0]){
		return simulate(edg[x][0], z + p[x][0]);
	} else {
		return simulate(edg[x][1], z + p[x][1]);
	}
}
#include "dungeons.h"
#include <vector>
using namespace std;

const int MAXN = 4e5 + 123;
int n;
int edg[MAXN][2];
int p[MAXN][2];

void init(int sn, vector<int> sv, vector<int> pv, vector<int> wv, vector<int> lv) {
	n = sn;
	for(int i = 0; i < n; ++i){
		edg[i][0] = wv[i];
		edg[i][1] = lv[i];
		p[i][0] = pv[i];
		p[i][1] = sv[i];
	}
	return;
}

long long simulate(int x, int z) {
	if(x >= n)
		return z;
	if(z >= p[x][0]){
		return simulate(edg[x][0], z + p[x][0]);
	} else {
		return simulate(edg[x][1], z + p[x][1]);
	}
}


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

dungeons.cpp:34:11: error: redefinition of 'const int MAXN'
   34 | const int MAXN = 4e5 + 123;
      |           ^~~~
dungeons.cpp:5:11: note: 'const int MAXN' previously defined here
    5 | const int MAXN = 4e5 + 123;
      |           ^~~~
dungeons.cpp:35:5: error: redefinition of 'int n'
   35 | int n;
      |     ^
dungeons.cpp:6:5: note: 'int n' previously declared here
    6 | int n;
      |     ^
dungeons.cpp:36:5: error: redefinition of 'int edg [400123][2]'
   36 | int edg[MAXN][2];
      |     ^~~
dungeons.cpp:7:5: note: 'int edg [400123][2]' previously declared here
    7 | int edg[MAXN][2];
      |     ^~~
dungeons.cpp:37:5: error: redefinition of 'int p [400123][2]'
   37 | int p[MAXN][2];
      |     ^
dungeons.cpp:8:5: note: 'int p [400123][2]' previously declared here
    8 | int p[MAXN][2];
      |     ^
dungeons.cpp:39:6: error: redefinition of 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)'
   39 | void init(int sn, vector<int> sv, vector<int> pv, vector<int> wv, vector<int> lv) {
      |      ^~~~
dungeons.cpp:10:6: note: 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)' previously defined here
   10 | void init(int sn, vector<int> sv, vector<int> pv, vector<int> wv, vector<int> lv) {
      |      ^~~~
dungeons.cpp:50:11: error: redefinition of 'long long int simulate(int, int)'
   50 | long long simulate(int x, int z) {
      |           ^~~~~~~~
dungeons.cpp:21:11: note: 'long long int simulate(int, int)' previously defined here
   21 | long long simulate(int x, int z) {
      |           ^~~~~~~~