Submission #283828

# Submission time Handle Problem Language Result Execution time Memory
283828 2020-08-26T07:41:54 Z mohammad Toy Train (IOI17_train) C++14
0 / 100
10 ms 896 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] ;
}

int root[150010];

ll find(int u){
	if(root[u] == u)
		return u ;
	return root[u] = find(root[u]);
}


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 , 0);
	R = r;
	for(int i = 0; i < n ; ++i) root[i] = i ;
	for(int i = 0 ; i < m ; ++i){
		int x = u[i] , y = v[i];
		root[find(x)] = find(y);
		// 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){
		find(i);
		if(r[i] == 1) w[root[i]] = 1;
	}
	for(int i = 0 ; i < n ; ++i) w[i] = w[root[i]];
	// for(int i = 0 ; i < n ; ++i){
	// 	if(w[i] != -1) continue ;
	// 	dfs(i);
	// }
	return w;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 896 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 812 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 896 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -