답안 #703899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703899 2023-02-28T19:33:05 Z Abrar_Al_Samit 장난감 기차 (IOI17_train) C++17
11 / 100
11 ms 1848 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;

const int nax = 5000;
int n, m;
vector<int>g[nax], gt[nax];
vector<int>A, R;
bool cyc[nax];
int vis[nax];

vector<int>stk;
vector<int>component;

void dfs1(int v) {
	vis[v] = 1;
	for(int u : g[v]) if(!vis[u]) {
		dfs1(u);
	}
	stk.push_back(v);
}
void dfs2(int v) {
	vis[v] = 1;
	component.push_back(v);
	for(int u : gt[v]) if(!vis[u]) {
		dfs2(u);
	}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n = a.size(), m = u.size();
	for(int i=0; i<m; ++i) {
		g[u[i]].push_back(v[i]);
		gt[v[i]].push_back(u[i]);
		if(u[i]==v[i]) cyc[u[i]] = true;
	}

	A = a, R = r;
	vector<int>res(n);

	for(int i=0; i<n; ++i) if(!vis[i]) {
		dfs1(i);
	}
	reverse(stk.begin(), stk.end());
	memset(vis, 0, sizeof vis);
	for(int v : stk) if(!vis[v]) {
		dfs2(v);

		if(component.size()>1) {
			for(int x : component) {
				cyc[x] = true;
			}
		}
		component.clear();
	}


	queue<int>q;
	for(int i=0; i<n; ++i) if(R[i] && cyc[i]) {
		q.push(i);
		res[i] = 1;
	}

	while(!q.empty()) {
		int v = q.front(); q.pop();
		for(int u : gt[v]) if(res[u]!=1) {
			q.push(u);
			res[u] = 1;
		}
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1492 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1776 KB Output is correct
2 Correct 6 ms 1832 KB Output is correct
3 Correct 6 ms 1708 KB Output is correct
4 Correct 8 ms 1748 KB Output is correct
5 Correct 8 ms 1704 KB Output is correct
6 Correct 8 ms 1708 KB Output is correct
7 Correct 11 ms 1616 KB Output is correct
8 Correct 7 ms 1708 KB Output is correct
9 Correct 9 ms 1620 KB Output is correct
10 Correct 7 ms 1620 KB Output is correct
11 Correct 7 ms 1620 KB Output is correct
12 Correct 6 ms 1540 KB Output is correct
13 Correct 8 ms 1748 KB Output is correct
14 Correct 9 ms 1824 KB Output is correct
15 Correct 8 ms 1832 KB Output is correct
16 Correct 10 ms 1748 KB Output is correct
17 Correct 8 ms 1848 KB Output is correct
18 Correct 5 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1576 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1620 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1492 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -