답안 #703901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703901 2023-02-28T19:38:24 Z Abrar_Al_Samit 장난감 기차 (IOI17_train) C++17
11 / 100
10 ms 1716 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] && !R[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] && !R[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] && !R[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;
		}
	}
	for(int i=0; i<n; ++i) res[i] ^= 1;

	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1108 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1620 KB Output is correct
2 Correct 7 ms 1492 KB Output is correct
3 Correct 6 ms 1508 KB Output is correct
4 Incorrect 7 ms 1492 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1160 KB Output is correct
2 Correct 6 ms 1492 KB Output is correct
3 Correct 10 ms 1620 KB Output is correct
4 Correct 7 ms 1580 KB Output is correct
5 Correct 7 ms 1608 KB Output is correct
6 Correct 7 ms 1608 KB Output is correct
7 Correct 7 ms 1620 KB Output is correct
8 Correct 7 ms 1572 KB Output is correct
9 Correct 6 ms 1468 KB Output is correct
10 Correct 7 ms 1588 KB Output is correct
11 Correct 7 ms 1540 KB Output is correct
12 Correct 7 ms 1620 KB Output is correct
13 Correct 7 ms 1716 KB Output is correct
14 Correct 7 ms 1620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1592 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1108 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -