답안 #584707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584707 2022-06-27T21:21:28 Z 1ne 장난감 기차 (IOI17_train) C++14
0 / 100
2000 ms 1740 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,0);
	vector<vector<int>>adj(n);
	for (int i = 0;i<m;++i){
		adj[u[i]].push_back(v[i]);
	}
	vector<int>visited(n,0);
	vector<int>cnt(n,0);
	vector<int>parent(n,-1);
	function<int(int)>dfs = [&](int u){
		if (visited[u] ==  2)return (cnt[u] | ans[u]);
		visited[u] = 1;
		int ans = 0;
		for (auto x:adj[u]){
			if (visited[x] == 1){
				int y = u;
				vector<int>temp;
				int got = r[x];
				temp.push_back(x);
				while(y!=x){
					got|=r[y];
					temp.push_back(y);
					y = parent[y];
				}
				ans |= got;
				for (auto y:temp)cnt[y]|=got;
			}
			else{
				parent[x] = u;
				ans|=dfs(x);
			}
		}
		visited[u] = 2;
		return cnt[u] |= ans;
	};	
	for (int i = 0;i<n;++i){
		for (int j = 0;j<n;++j)visited[j] = false;
		ans[i] = dfs(i);	
	}
	for (int j = 0;j<n;++j){
		for (int i = 0;i<m;++i){
				cnt[u[i]]|=cnt[v[i]];
		}
	}
	for (int i = 0;i<n;++i){
		ans[i]|=cnt[i];
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 637 ms 1512 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 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 814 ms 1740 KB Output is correct
2 Correct 879 ms 1648 KB Output is correct
3 Correct 936 ms 1612 KB Output is correct
4 Execution timed out 2081 ms 1496 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2088 ms 1284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2035 ms 1428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 637 ms 1512 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -