답안 #671535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671535 2022-12-13T07:31:38 Z coding_snorlax 장난감 기차 (IOI17_train) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;
#define pb push_back
int vis[5005]={0};
int rev_answer[5005]={0};
vector<int> answer;
vector<int> G[5005];
vector<int> rev_G[5005];
int charge[5005]={0};
int flag=-1;
void dfs(int node){
    //cout<<"dfs node: "<<node;
    vis[node]=1;
    for(int i:G[node]){
        if(!vis[i] && !charge[i]) dfs(i);
        if(vis[i]) flag=i;
    }
}
void rev_dfs(int node){
    //cout<<"rev_dfs node: "<<node;
    vis[node]=1;
    for(int i:rev_G[node]){
        if(!vis[i]){
           rev_answer[i]=1;
           rev_dfs(i);
        }
    }
}

vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v){
    for(int i=0;i<(int)r.size();i++){
        charge[i]=r[i];
    }
    for(int i=0;i<(int)u.size();i++){
        G[u[i]].push_back(v[i]);
        rev_G[v[i]].push_back(u[i]);
    }
    for(int i=0;i<(int)a.size();i++){
        flag=-1;
        for(int j=0;j<(int)a.size();j++){
            vis[j]=0;
        }
        if(!charge[i]) dfs(i);
        for(int j=0;j<(int)a.size();j++){
            vis[j]=0;
        }
        if(flag!=-1) rev_dfs(flag);
    }

    for(int i=0;i<(int)a.size();i++){
        flag=-1;
        for(int j=0;j<(int)a.size();j++){
            vis[j]=0;
        }
        if(!charge[i]) dfs(i);
        for(int j=0;j<(int)a.size();j++){
            vis[j]=0;
        }
        if(flag!=-1) rev_dfs(flag);
    }
    for(int i=0;i<(int)a.size();i++){
        if(!rev_answer[i]) answer.pb(1);
        else answer.pb(0);
    }
    return answer;

}
int main(){
    vector<int> a = {0,0,0,0,0,0};
    vector<int> r = {0,0,0,0,0,1};
    vector<int> u = {0,0,1,3,4,2};
    vector<int> v = {1,2,3,4,1,5};
    auto b = who_wins(a, r, u, v);
    for(int i:b) cout<<i<<" ";
}

Compilation message

/usr/bin/ld: /tmp/ccklSAie.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoi4n6d.o:train.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status