Submission #282322

# Submission time Handle Problem Language Result Execution time Memory
282322 2020-08-24T09:53:08 Z MohamedAhmed04 Toy Train (IOI17_train) C++14
0 / 100
716 ms 1416 KB
#include <bits/stdc++.h>
#include "train.h"
//#include "grader.cpp"

using namespace std ;

const int MAX = 5010 ;

int A[MAX] , R[MAX] ;
vector< vector<int> >adj(MAX) ;
int n ;

int vis[MAX] , mark[MAX] ;

bool dfs(int node)
{
	vis[node] = 1 , mark[node] = 1 ;
	if(R[node])
		return A[node] ;
	for(auto &child : adj[node])
	{
		if(vis[child])
		{
			if(mark[child] && !A[node])
			{
				mark[node] = 0 ;
				return 1 ;
			}
			continue ;
		}
		bool t = dfs(child) ;
		if(A[node] && A[child] == t)
		{
			mark[node] = 0 ;
			return 1 ;
		}
		else if(!A[node] && A[child] != t)
		{
			mark[node] = 0 ;
			return 1 ;
		}
	}
	return 0 ;
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) 
{
	n = a.size() ;
	int m = u.size() ;
	for(int i = 1 ; i <= n ; ++i)
	{
		A[i] = a[i-1] ;
		R[i] = r[i-1] ;
	}
	for(int i = 0 ; i < m ; ++i)
		adj[u[i] + 1].push_back(v[i] + 1) ;
	vector<int>ans ;
	for(int i = 1 ; i <= n ; ++i)
	{
		memset(vis , 0 , sizeof(vis)) ;
		bool t = dfs(i) ;
		if(A[i] == t)
			ans.push_back(1) ;
		else
			ans.push_back(0) ;
	}
	return ans ;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 896 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 1280 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1024 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 716 ms 1416 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 Incorrect 8 ms 896 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -