# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
409813 |
2021-05-21T15:22:24 Z |
dreezy |
Toy Train (IOI17_train) |
C++17 |
|
2000 ms |
1484 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<vector<int>> graph;
vector<bool> vis;
vector<int> a, r,w;
bool dfs(int n, int energy, bool charger){
//cout << n << ", "<<energy <<", "<<charger<<endl;
if(energy < 0 ) {
w[n] = true;
vis[n] = false;
return false;
}
if(vis[n]){
vis[n] = false;
if(charger){
w[n] = true;
return true;
}
w[n] = false;
return false;
}
vis[n] = true;
for(int adj : graph[n]){
if(r[adj]){
energy = n;
charger = true;
}
bool res = dfs(adj, energy--,charger);
if( a[adj] == 1 && res){
w[adj] = true;
return true;
}
if(a[adj] == 0 && !res){
w[adj] = false;
return false;
}
}
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);
w.assign(n, 0);
a = a_;
r=r_;
for(int i =0; i< m;i++){
graph[u[i]].pb(v[i]);
}
for(int i=0; i<n;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 |
848 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 |
1 ms |
280 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2064 ms |
1484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1144 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1228 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
848 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |