Submission #411197

# Submission time Handle Problem Language Result Execution time Memory
411197 2021-05-24T16:04:56 Z Jasiekstrz Toy Train (IOI17_train) C++17
23 / 100
1796 ms 149796 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;
const int N=5e3;
bool ab[N+10];
bool charge[N+10];
int deg[N+10];
vector<int> e[N+10];
int vis[N+10];
vector<int> f[N+10];
bool loop[N+10];
void dfs(int x,int c)
{
	f[x].push_back(c);
	for(auto v:e[x])
	{
		vis[v]--;
		if(vis[v]==0)
		{
			if(v==c)
				loop[c]=true;
			else
				dfs(v,c);
		}
	}
	return;
}
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<n;i++)
	{
		ab[i]=a[i];
		charge[i]=r[i];
	}
	for(int i=0;i<m;i++)
	{
		e[v[i]].push_back(u[i]);
		deg[u[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			vis[j]=(ab[j] ? 1:deg[j]);
		dfs(i,i);
	}
	vector<int> ans(n);
	for(int i=0;i<n;i++)
	{
		ans[i]=0;
		for(auto ch:f[i])
		{
			if(charge[ch] && loop[ch])
			{
				ans[i]=1;
				break;
			}
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 1088 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 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 665 ms 70336 KB Output is correct
2 Correct 653 ms 69616 KB Output is correct
3 Correct 658 ms 69916 KB Output is correct
4 Correct 1505 ms 146768 KB Output is correct
5 Correct 1167 ms 111176 KB Output is correct
6 Correct 859 ms 69072 KB Output is correct
7 Correct 762 ms 67076 KB Output is correct
8 Correct 457 ms 53444 KB Output is correct
9 Correct 453 ms 46532 KB Output is correct
10 Correct 492 ms 52224 KB Output is correct
11 Correct 472 ms 45208 KB Output is correct
12 Correct 63 ms 4804 KB Output is correct
13 Correct 1714 ms 149796 KB Output is correct
14 Correct 1686 ms 149424 KB Output is correct
15 Correct 1692 ms 149160 KB Output is correct
16 Correct 1630 ms 148676 KB Output is correct
17 Correct 1680 ms 149620 KB Output is correct
18 Correct 751 ms 69748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1228 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 Correct 84 ms 1760 KB Output is correct
2 Correct 1796 ms 147952 KB Output is correct
3 Correct 777 ms 44936 KB Output is correct
4 Correct 1429 ms 87044 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 195 ms 13348 KB Output is correct
7 Correct 31 ms 1868 KB Output is correct
8 Correct 25 ms 1732 KB Output is correct
9 Correct 26 ms 1740 KB Output is correct
10 Correct 3 ms 716 KB Output is correct
11 Correct 58 ms 4200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 1088 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -