Submission #72863

# Submission time Handle Problem Language Result Execution time Memory
72863 2018-08-27T06:08:56 Z Sa1378 Toy Train (IOI17_train) C++17
11 / 100
18 ms 4732 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define N ((int)11*1000)

int n,m,cnt;
bool self[N],ans[N],mark[N];
vector <int> e[N],er[N],tpl;

void dfs(int x,vector <int> &r)
{
	mark[x]=1;
	for(auto u:e[x])
		if(!mark[u] && !r[u])
			dfs(u,r);
	tpl.push_back(x);
}

void dfs2(int x,vector <int> &r)
{
	mark[x]=1;cnt++;
	for(auto u:er[x])
		if(!mark[u] && !r[u])
			dfs2(u,r);
}

void dfs_ans(int x)
{
	ans[x]=1;
	for(auto u:er[x])
		if(!ans[u])
			dfs_ans(u);
}

vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v)
{
	int n=a.size(),m=u.size();
	for(int i=0;i<m;i++)
	{
		if(u[i]==v[i])self[u[i]]=1;
		else e[u[i]].push_back(v[i]),er[v[i]].push_back(u[i]);
	}
	for(int i=0;i<n;i++)
		if(!mark[i] && !r[i])
			dfs(i,r);
	reverse(tpl.begin(),tpl.end());
	memset(mark,0,sizeof mark);
	for(auto u:tpl)
		if(!mark[u])
		{
			cnt=0;
			dfs2(u,r);
			if(cnt>1 || self[u])dfs_ans(u);
		}
	vector <int> res;
	for(int i=0;i<n;i++)res.push_back(1-ans[i]);
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1656 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 3 ms 1656 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 Correct 17 ms 2228 KB Output is correct
2 Correct 11 ms 2228 KB Output is correct
3 Correct 11 ms 2228 KB Output is correct
4 Incorrect 13 ms 2228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2228 KB Output is correct
2 Correct 14 ms 2228 KB Output is correct
3 Correct 14 ms 2492 KB Output is correct
4 Correct 15 ms 2744 KB Output is correct
5 Correct 13 ms 2868 KB Output is correct
6 Correct 15 ms 3060 KB Output is correct
7 Correct 17 ms 3272 KB Output is correct
8 Correct 18 ms 3460 KB Output is correct
9 Correct 11 ms 3488 KB Output is correct
10 Correct 15 ms 3840 KB Output is correct
11 Correct 15 ms 4048 KB Output is correct
12 Correct 14 ms 4304 KB Output is correct
13 Correct 16 ms 4596 KB Output is correct
14 Correct 16 ms 4672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 4732 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 7 ms 1656 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -