답안 #799863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799863 2023-08-01T07:15:06 Z LittleCube 장난감 기차 (IOI17_train) C++17
0 / 100
359 ms 1664 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

int n, m, dead[5000];
vector<int> E[5000], R[5000];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
	n = a.size(), m = u.size();
	vector<int> ans(n, 1);
	while (1)
	{
		for (int i = 0; i < n; i++)
			E[i].clear(), R[i].clear();
		for (int i = 0; i < m; i++)
			if (!dead[u[i]] && !dead[v[i]])
			{
				E[u[i]].emplace_back(v[i]);
				R[v[i]].emplace_back(u[i]);
			}
		vector<int> req(n, 0), vis(n, 0);
		for (int i = 0; i < n; i++)
			if (!dead[i])
			{
				if (a[i])
					req[i] = 1;
				else
					req[i] = E[i].size();
			}
		queue<int> q;
		for (int i = 0; i < n; i++)
			if (!dead[i] && r[i])
			{
				vis[i] = 1;
				q.emplace(i);
			}

		while (!q.empty())
		{
			int i = q.front();
			q.pop();
			for (auto j : R[i])
				if(--req[j] == 0)
				{
					vis[j] = 1;
					q.emplace(j);
				}
		}

		for (int i = 0; i < n; i++)
			if (!dead[i] && vis[i])
			{
				if (a[i])
					req[i] = E[i].size();
				else
					req[i] = 1;
			}
		for (int i = 0; i < n; i++)
			if(!dead[i] && !vis[i])
				q.emplace(i);
		if(q.empty())
			break;
		while (!q.empty())
		{
			int i = q.front();
			ans[i] = 0, dead[i] = 1;
			q.pop();
			for (auto j : R[i])
				if(--req[j] == 0)
					q.emplace(j);
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1016 KB 3rd lines differ - on the 22nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Incorrect 0 ms 468 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 1460 KB Output is correct
2 Correct 282 ms 1664 KB Output is correct
3 Correct 359 ms 1656 KB Output is correct
4 Correct 6 ms 1620 KB Output is correct
5 Incorrect 7 ms 1612 KB 3rd lines differ - on the 25th token, expected: '1', found: '0'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1236 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1364 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1016 KB 3rd lines differ - on the 22nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -