# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1076864 |
2024-08-26T17:29:02 Z |
Gray |
Toy Train (IOI17_train) |
C++17 |
|
9 ms |
2648 KB |
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ff first
#define ss second
#define ln "\n"
#define ld long double
vector<ll> are;
vector<ll> isc;
vector<vector<ll>> A;
ll n, m;
void dfs(ll u, vector<ll> &dp){
dp[u]=-2;
bool spec=0;
for (auto v:A[u]){
if (v==u) spec=1;
if (dp[v]==-1) {dfs(v, dp); dp[u]=dp[v];}
}
if (spec){
if (isc[u] and are[u]){
dp[u]=1;
}else{
if (!isc[u] and !are[u]) dp[u]=0;
else if (dp[u]!=-2) dp[u]=0;
}
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n=a.size(); m=v.size();
isc=r; are=a;
A.clear(); A.resize(n);
for (ll i=0; i<m; i++){
A[u[i]].push_back(v[i]);
}
vector<int> dp(n, -1);
for (ll i=0; i<n; i++){
if (dp[i]==-1) dfs(i, dp);
assert(dp[i]!=-2);
}
return dp;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
2392 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2392 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
2140 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
2648 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
2392 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |