Submission #1025831

# Submission time Handle Problem Language Result Execution time Memory
1025831 2024-07-17T10:37:41 Z amirhoseinfar1385 Toy Train (IOI17_train) C++17
0 / 100
2000 ms 1884 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=30000+10;
vector<int>adj[maxn];
int n,shar[maxn],arez[maxn],m,dp[maxn],vas[maxn],dide[maxn];

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	n=(int)a.size();
	m=(int)u.size();
	for(int i=0;i<=n;i++){
		adj[i].clear();
		shar[i]=vas[i]=dide[i]=dp[i]=arez[i]=0;
	}
	for(int i=0;i<n;i++){
		if(a[i]){
			arez[i]=1;
		}
		if(r[i]){
			shar[i]=1;
		}
	}
	for(int i=0;i<m;i++){
		adj[u[i]].push_back(v[i]);
	}
	for(int nago=0;nago<=n;nago++){
	for(int i=0;i<n;i++){
		dp[i]=shar[i];
	}
	for(int asd=0;asd<=n;asd++){
		for(int i=0;i<n;i++){
			if(dp[i]){
				continue;
			}
			int cnt=0;
			int f=0;
			for(auto x:adj[i]){
				if(dp[x]==1){
					cnt++;
				}
			}
			if(arez[i]){
				if(cnt>0){
					dp[i]=1;
				}
			}else{
				exit(23);
				if(f){
					if(shar[i]==0||cnt!=(int)adj[i].size()-1){
						dp[i]=0;
					}
				}else{
					if(cnt!=(int)adj[i].size()){
						dp[i]=0;
					}
				}
			}
		}
	}
	if(nago!=n){
		for(int i=0;i<n;i++){
			if(shar[i]==1){
				int cnt=0;
				for(auto x:adj[i]){
					if(dp[x]==1){
						cnt++;
					}
				}
				shar[i]=(cnt==1);
			}
		}
	}
	}
	vector<int>res(n);
	for(int i=0;i<n;i++){
		res[i]=dp[i];
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1368 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1116 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2078 ms 1884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1628 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1856 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1368 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -