답안 #72905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72905 2018-08-27T08:09:51 Z Navick 장난감 기차 (IOI17_train) C++17
11 / 100
17 ms 2092 KB
#include <bits/stdc++.h>
#include "train.h"

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxN = 5e3 + 10;

bool t[maxN];
int num[maxN], c[maxN], a[maxN], sz[maxN];

vector <int> adj[maxN], rev[maxN], topol;
bool mark[maxN];

void DFS(int v)
{
	mark[v] = true;
	for (auto u : adj[v])
		if(!mark[u]) DFS(u);
	topol.pb(v);
}

void SFD(int v, int comp)
{
	mark[v] = true;
	sz[comp] ++;
	num[v] = comp;

	for (auto u : rev[v])
		if(!mark[u]) SFD(u, comp);
}

void sfd(int v)
{
	mark[v] = true;
	for (auto u : rev[v])
		if(!mark[u]) sfd(u);
}

std::vector<int> who_wins(std::vector<int> A, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int n = A.size(), m = u.size();
	
	for (int i=0; i<n; i++) c[i] = r[i], a[i] = A[i];

	for (int i=0; i<m; i++)
	{
		adj[u[i]].pb(v[i]);
		rev[v[i]].pb(u[i]);
	
		if(u[i] == v[i]) t[u[i]] = true;
	}

	for (int i=0; i<n; i++)
		if(!mark[i]) DFS(i);

	reverse(topol.begin(), topol.end());
	memset(mark, 0, sizeof mark);
	
	int id = 0;
	for (auto v : topol)
		if(!mark[v]){
			SFD(v, id);
			id ++;
		}

	memset(mark, 0, sizeof mark);
	for (int i=0; i<n; i++)
	{
		if(!c[i]) continue ;
		int id = num[i];
		if(sz[id] > 1 || t[i]) sfd(i);
	}

	vector <int> ans;

	for (int i=0; i<n; i++)
		ans.pb(mark[i]);

	return ans;

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1400 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1400 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1820 KB Output is correct
2 Correct 10 ms 1864 KB Output is correct
3 Correct 13 ms 1864 KB Output is correct
4 Correct 13 ms 1864 KB Output is correct
5 Correct 13 ms 1876 KB Output is correct
6 Correct 17 ms 1876 KB Output is correct
7 Correct 15 ms 1876 KB Output is correct
8 Correct 17 ms 1948 KB Output is correct
9 Correct 12 ms 1948 KB Output is correct
10 Correct 15 ms 1948 KB Output is correct
11 Correct 12 ms 1948 KB Output is correct
12 Correct 13 ms 1948 KB Output is correct
13 Correct 16 ms 2092 KB Output is correct
14 Correct 15 ms 2092 KB Output is correct
15 Correct 14 ms 2092 KB Output is correct
16 Correct 15 ms 2092 KB Output is correct
17 Correct 13 ms 2092 KB Output is correct
18 Correct 9 ms 2092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 2092 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 2092 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1400 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -