Submission #797946

# Submission time Handle Problem Language Result Execution time Memory
797946 2023-07-30T07:42:40 Z LittleCube Toy Train (IOI17_train) C++17
0 / 100
419 ms 1624 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
	int n = a.size(), m = u.size();
	vector<vector<int>> E(n), R(n);
	for (int i = 0; i < m; i++)
		E[u[i]].emplace_back(v[i]),
			R[v[i]].emplace_back(u[i]);
	vector<int> loop(n, 0);
	for (int i = 0; i < n; i++)
	{
		vector<int> req(n, 0);
		for (int j = 0; j < n; j++)
			if (r[j])
				req[j] = 1e9;
			else if (a[j])
				req[j] = E[j].size();
			else
				req[j] = 1;
		queue<int> q;
		q.push(i);
		while (!q.empty())
		{
			int x = q.front();
			q.pop();
			for (auto y : R[x])
				if (--req[y] == 0)
					q.emplace(y);
		}
		loop[i] = req[i] <= 0;
	}
	vector<int> ans(n, 1);
	vector<int> req(n, 0);
	queue<int> q;

	for (int j = 0; j < n; j++)
		if (loop[j])
		{
			q.push(j);
			req[j] = 0;
		}
		else if (r[j])
			req[j] = 1e9;
		else if (a[j])
			req[j] = E[j].size();
		else
			req[j] = 1;

	while (!q.empty())
	{
		int x = q.front();
		ans[x] = 0;
		q.pop();
		for (auto y : R[x])
			if (--req[y] == 0)
				q.emplace(y);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 1108 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 1 ms 212 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 151 ms 1624 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 27 ms 1404 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 Correct 419 ms 1580 KB Output is correct
2 Correct 43 ms 1572 KB Output is correct
3 Correct 190 ms 1576 KB Output is correct
4 Correct 53 ms 1472 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 43 ms 1108 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 1108 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -