Submission #282366

# Submission time Handle Problem Language Result Execution time Memory
282366 2020-08-24T11:03:04 Z MohamedAhmed04 Toy Train (IOI17_train) C++14
0 / 100
17 ms 9760 KB
#include <bits/stdc++.h>
#include "train.h"
//#include "grader.cpp"
 
using namespace std ;
 
const int MAX = 16 ;
 
int A[MAX] , R[MAX] ;
vector< vector<int> >adj(MAX) ;
int n ;

int dp[MAX][(1 << MAX)] ;
vector<int>v ;
 
bool dfs(int node , int mask)
{
	int &ret = dp[node][mask] ;
	if(ret != -1)
		return ret ;
	v.push_back(node) ;
	ret = 0 ;
	for(auto &child : adj[node])
	{
		if((mask & (1 << child)))
		{
			bool flag = 0 , flag2 = 0 ;
			for(auto &i : v)
			{
				if(i == child)
					flag2 = 1 ;
				if(flag2)
					flag |= R[i] ;
			}
			if(flag == A[node])
				ret = 1 ;
			continue ;
		}
		bool t = dfs(child , mask | (1 << child)) ;
		if(A[node] && A[child] == t)
			ret = 1 ;
		else if(!A[node] && A[child] != t)
			ret = 1 ;
	}
	v.pop_back() ;
	return ret ;
}
 
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) 
{
	memset(dp , -1 , sizeof(dp)) ;
	n = a.size() ;
	int m = u.size() ;
	n = a.size() ;
	m = u.size() ;
	for(int i = 0 ; i < n ; ++i)
		A[i] = a[i] , R[i] = r[i] ;
	for(int i = 0 ; i < m ; ++i)
		adj[u[i]].push_back(v[i]) ;
	vector<int>ans ;
	for(int i = 0 ; i < n ; ++i)
	{
		bool t = dfs(i , 1 << i) ;
		if(A[i] == t)
			ans.push_back(1) ;
		else
			ans.push_back(0) ;
	}
	return ans ;
}
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4480 KB Output is correct
2 Correct 3 ms 4480 KB Output is correct
3 Correct 3 ms 4608 KB Output is correct
4 Correct 17 ms 4480 KB Output is correct
5 Correct 3 ms 4480 KB Output is correct
6 Incorrect 3 ms 4480 KB 3rd lines differ - on the 7th token, expected: '0', found: '1'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 9760 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 9600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 9728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -