답안 #283807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
283807 2020-08-26T07:30:19 Z mohammad 장난감 기차 (IOI17_train) C++14
5 / 100
187 ms 262148 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
 
#define endl "\n"
// #define int long long

typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7  ;
const int N = 10000010  ;

vector<int> g[5010] , w , R;

int dfs(int i){
	if(w[i] != -1)  return w[i];
	for(auto x : g[i])
		w[i] = dfs(x);
	if(w[i] == -1) w[i] = R[i];
	return w[i] ;
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size() , m = u.size();
	w = vector<int>(n , -1);
	R = r;
	for(int i = 0 ; i < m ; ++i){
		int x = u[i] , y = v[i];
		if(x == y && a[x] == 1 && r[x] == 1) w[x] = 1;
		if(x == y && a[x] == 0 && r[x] == 0) w[x] = 0;
		else if(x != y) g[x].push_back(y);
	}
	for(int i = 0 ; i < n ; ++i){
		if(w[i] != -1) continue ;
		dfs(i);
	}
	return w;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 896 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 7 ms 896 KB Output is correct
4 Correct 4 ms 896 KB Output is correct
5 Correct 4 ms 916 KB Output is correct
6 Correct 4 ms 896 KB Output is correct
7 Correct 4 ms 896 KB Output is correct
8 Correct 6 ms 896 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 4 ms 896 KB Output is correct
11 Correct 4 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 184 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1408 KB Output is correct
2 Correct 8 ms 1408 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Runtime error 187 ms 262148 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 172 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 178 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 896 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 7 ms 896 KB Output is correct
4 Correct 4 ms 896 KB Output is correct
5 Correct 4 ms 916 KB Output is correct
6 Correct 4 ms 896 KB Output is correct
7 Correct 4 ms 896 KB Output is correct
8 Correct 6 ms 896 KB Output is correct
9 Correct 4 ms 896 KB Output is correct
10 Correct 4 ms 896 KB Output is correct
11 Correct 4 ms 768 KB Output is correct
12 Runtime error 184 ms 262148 KB Execution killed with signal 9
13 Halted 0 ms 0 KB -