Submission #296606

# Submission time Handle Problem Language Result Execution time Memory
296606 2020-09-10T17:04:27 Z Dovran Toy Train (IOI17_train) C++11
0 / 100
14 ms 5248 KB
#include <bits/stdc++.h>
#include "train.h"

#define N 20009
#define pii pair <int, int>
#define ff first
#define ss second
#define sz() size()
#define pb push_back
#define ll long long

using namespace std;

bool a[N];
vector<int>ans;
int asd=0;
int vis[N], c[N];
map<int, int>M[N];

void dfs(int nd){
	vis[nd]=1;
	if(a[nd]){
		asd=1;
		return;
	}
	if(M[nd][nd+1] and !vis[nd+1])
		dfs(nd+1);
	a[nd]=asd;
}

std::vector<int> who_wins(std::vector<int>o, std::vector<int>p, std::vector<int>u, std::vector<int>v){
	int n=o.sz();
	int m=u.sz();
	for(int i=0; i<m; i++){
		M[u[i]][v[i]]=1;
		if(u[i]==v[i])
			c[u[i]]=1;
	}
	for(int i=0; i<n; i++)
		if(p[i]==1 and o[i]==1 and c[i]==1)
			a[i]=1;
	for(int i=0; i<n; i--){
		if(!a[i] and !vis[i])
			asd=0, dfs(i);
		
		ans.pb(a[i]);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 3584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 2408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 5248 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 4608 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 5240 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 3584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -