답안 #406827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406827 2021-05-18T05:45:24 Z 8e7 장난감 기차 (IOI17_train) C++14
0 / 100
10 ms 1816 KB
#include "train.h"

//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ll long long
#define maxn 5005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
vector<int> adj[maxn], rev[maxn];
bool found[maxn], poss[maxn];
int ord[maxn];
int ti = 0;
void dfs(int n) {
	found[n] = 1;
	for (int v:adj[n]) {
		if (!found[v]) {
			dfs(v);
		}
	}

	ord[ti++] = n;
}
vector<int> node;
void dfs2(int n) {
	node.push_back(n);
	found[n] = 1;
	for (int v:rev[n]) {
		if (!found[v]) dfs2(v);
	}
}
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 < m;i++) {
		adj[u[i]].push_back(v[i]);
		rev[v[i]].push_back(u[i]);
	}
	for (int i = 0;i < n;i++) {
		if (!found[i]) dfs(i);
	}
	for (int i = 0;i < n;i++) found[i] = 0;
	for (int i = n - 1;i >= 0;i--) {
		if (!found[ord[i]]) {
			node.clear();
			dfs2(ord[i]);
			int ans = 0;
			for (int j:node) ans |= r[j];
			for (int j:node) poss[j] = ans;
		}
	}	
	vector<int> ret;
	for (int i = 0;i < n;i++) {
		if (poss[i]) ret.push_back(1);
		else ret.push_back(0);
	}
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1356 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1816 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1484 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1740 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1356 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -