Submission #72860

# Submission time Handle Problem Language Result Execution time Memory
72860 2018-08-27T06:02:46 Z Sa1378 Toy Train (IOI17_train) C++17
11 / 100
21 ms 4908 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],flg;
vector <int> e[N],er[N],tpl;

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

void dfs2(int x,vector <int> &r)
{
	mark[x]=1;
	cnt++;flg|=r[x];
	for(auto u:er[x])
		if(!mark[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])
			dfs(i);
	reverse(tpl.begin(),tpl.end());
	memset(mark,0,sizeof mark);
	for(auto u:tpl)
		if(!mark[u])
		{
			flg=0;cnt=0;
			dfs2(u,r);
			if(flg && (cnt>1 || self[u]))dfs_ans(u);
		}
	vector <int> res;
	for(int i=0;i<n;i++)res.push_back(ans[i]);
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1784 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 3 ms 1784 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2208 KB Output is correct
2 Correct 17 ms 2208 KB Output is correct
3 Correct 13 ms 2256 KB Output is correct
4 Correct 13 ms 2256 KB Output is correct
5 Correct 16 ms 2412 KB Output is correct
6 Correct 21 ms 2704 KB Output is correct
7 Correct 15 ms 2704 KB Output is correct
8 Correct 13 ms 3036 KB Output is correct
9 Correct 15 ms 3112 KB Output is correct
10 Correct 16 ms 3308 KB Output is correct
11 Correct 16 ms 3424 KB Output is correct
12 Correct 13 ms 3568 KB Output is correct
13 Correct 19 ms 4008 KB Output is correct
14 Correct 17 ms 4344 KB Output is correct
15 Correct 20 ms 4424 KB Output is correct
16 Correct 15 ms 4632 KB Output is correct
17 Correct 16 ms 4840 KB Output is correct
18 Correct 11 ms 4840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 4840 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 14 ms 4908 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1784 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -