답안 #593792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593792 2022-07-11T15:26:09 Z FatihSolak 장난감 기차 (IOI17_train) C++17
컴파일 오류
0 ms 0 KB
#include "train.h"
#include <bits/stdc++.h>
#define N 5005
using namespace std;
int path[N][N];
int path2[N][N];
bool special[N];
vector<int> adj[N];
vector<int> adj2[N];
void dfs(int v,int num){
	path[num][v] = 1;
	for(auto u:adj[v]){
		if(!path[num][u]){
			dfs(u,num);
		}
	}
}
void dfs(int v,int num){
	path2[num][v] = 1;
	for(auto u:adj2[v]){
		if(!path2[num][u]){
			dfs2(u,num);
		}
	}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size();
	int m = u.size();
	for(int i=0;i<m;i++){
		adj[u[i]].push_back(v[i]);
		if(!r[v[i]])
			adj2[u[i]].push_back(v[i]);
	}
	for(int i = 0;i<n;i++){
		dfs(i,i);
		dfs2(i,i);
	}
	for(int i = 0;i<n;i++){
		if(!r[i]){
			for(auto u:adj[i]){
				if(path2[u][i] && !r[u]){
					special[i] = 1;
				}
			}
		}
	}
	vector<int> res(n);
	for(int i = 0; i < n; i++){
		res[i] = 1;
		for(int j = 0;j<n;j++){
			if(special[j] && path[i][j]){
				res[i] = 0;
			}
		}
	}
	return res;
}

Compilation message

train.cpp:18:6: error: redefinition of 'void dfs(int, int)'
   18 | void dfs(int v,int num){
      |      ^~~
train.cpp:10:6: note: 'void dfs(int, int)' previously defined here
   10 | void dfs(int v,int num){
      |      ^~~
train.cpp: In function 'void dfs(int, int)':
train.cpp:22:4: error: 'dfs2' was not declared in this scope; did you mean 'dfs'?
   22 |    dfs2(u,num);
      |    ^~~~
      |    dfs
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:36:3: error: 'dfs2' was not declared in this scope; did you mean 'dfs'?
   36 |   dfs2(i,i);
      |   ^~~~
      |   dfs