Submission #409826

# Submission time Handle Problem Language Result Execution time Memory
409826 2021-05-21T15:40:40 Z dreezy Toy Train (IOI17_train) C++17
0 / 100
125 ms 1256 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<vector<int>> graph;
vector<bool> vis;
vector<int> r;

bool dfs(int n, int energy, bool charger){
	//cout << n << ", "<<energy <<", "<<charger<<endl;
	if(energy < 0 ) {
		return false;
	}
	if(vis[n]){
		if(charger){
			return true;
		}
		return false;
	}
	
	vis[n] = true;
	
	
	for(int adj : graph[n]){
		if(r[adj]){
			energy = r.size();
			charger = true;
		}
		bool res = dfs(adj, energy--,charger);
		
		if( res){
			return true;
		}
		
	}
	
	return false;
	
}

vector<int> who_wins(vector<int> a_, vector<int> r_, vector<int> u , vector<int> v){
	int n = a_.size();
	int m = u.size();
	graph.assign(n, {});
	vis.assign(n, 0);
	vector<int> w(n,0);
	r=r_;
	for(int i =0; i< m;i++){
		graph[u[i]].pb(v[i]);
		//cout << u[i]<<" ->" <<v[i]<<endl;
	}
	
	for(int i=0; i<n;i++){
		//cout << i<<": "<<endl;
		vis.assign(n, 0);
		w[i] = dfs(i, n , r_[i]);
	}
	

	return w;
}

/*
int main(){
	int n, m; cin >> n >>m;
	vector<int> a_(n), r_(n), u(m) ,v(m);
	for(int i  = 0; i<n; i++){
		cin >> a_[i];
	}
	for(int i =0; i< n; i++)
		cin >> r_[i];
	for(int i =0; i<m; i++)
	cin >> u[i];
	for(int i =0; i<m;i++)
	cin >> v[i];
	
	vector<int> w_ = who_wins(a_,r_,u,v);
	for(int i=0; i< n ;i++)
		cout << w_[i]<<endl;
}
*/
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 716 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 204 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 125 ms 1256 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 10 ms 844 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 9 ms 1052 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 716 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -