답안 #584676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584676 2022-06-27T19:07:41 Z 1ne 장난감 기차 (IOI17_train) C++14
0 / 100
6 ms 1492 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int n = (int)a.size();
	int m = (int)u.size();
	vector<int>ans(n);
	vector<vector<int>>adj(n);
	for (int i = 0;i<m;++i){
		adj[u[i]].push_back(v[i]);
	}
	vector<bool>visited(n,false);
	int counts = 0;
	vector<int>dfs_initial(n,0);
	vector<int>dfs_low(n,0);
	vector<int>s;
	function<void(int)>dfs = [&](int u){
		visited[u] = true;
		s.push_back(u);
		dfs_initial[u] = dfs_low[u] = ++counts;
		for (auto x:adj[u]){
			if (!dfs_low[x]){
				dfs(x);
			}
			if (visited[x]){
				dfs_low[u] = min(dfs_low[u],dfs_low[x]);
			}
		}
		if (dfs_low[u] == dfs_initial[u]){
			vector<int>temp;
			int got = 0;
			while(true){
				int v = s.back();
				s.pop_back();
				visited[v] = false;
				temp.push_back(v);
				got|=r[v];
				if (v==u)break;
			}
			if (got == 1){
				for (auto x:temp){
					ans[x] = got;
				}
			}
		}
	};
	for (int i = 0;i<n;++i){
		if (!dfs_low[i])dfs(i);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1364 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st 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: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1236 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1492 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1364 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -