# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1076814 |
2024-08-26T16:51:15 Z |
Gray |
Toy Train (IOI17_train) |
C++17 |
|
5 ms |
1412 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 (isc[u] and are[u] and spec){
dp[u]=1;
}else if (spec and !isc[u]) dp[u]=0;
if (dp[u]==-2){
if (isc[u] and spec) dp[u]=1;
else 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);
}
return dp;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1112 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 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 |
Correct |
4 ms |
1372 KB |
Output is correct |
2 |
Correct |
3 ms |
1412 KB |
Output is correct |
3 |
Correct |
4 ms |
1372 KB |
Output is correct |
4 |
Incorrect |
5 ms |
1372 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1116 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 |
4 ms |
1140 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 |
3 ms |
1112 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |