Submission #671536

# Submission time Handle Problem Language Result Execution time Memory
671536 2022-12-13T07:31:50 Z coding_snorlax Toy Train (IOI17_train) C++14
0 / 100
2000 ms 1664 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;
 
}
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 1144 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 468 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 541 ms 1664 KB 3rd lines differ - on the 1663rd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1276 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2078 ms 1532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 1144 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -