# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
826227 |
2023-08-15T11:21:39 Z |
vnm06 |
Toy Train (IOI17_train) |
C++14 |
|
556 ms |
3364 KB |
#include<bits/stdc++.h>
#include "train.h"
using namespace std;
int n, m;
bool isC[5005], used[5005];
vector<int> gr[5005], rev_gr[5005];
void dfs(int v)
{
int brs=gr[v].size();
for(int i=0; i<brs; i++)
{
int nv=gr[v][i];
if(used[nv]) continue;
used[nv]=1;
dfs(nv);
}
}
vector<int> ans;
void dfs2(int v)
{
ans[v-1]=1;
int brs=rev_gr[v].size();
for(int i=0; i<brs; i++)
{
int nv=rev_gr[v][i];
if(ans[nv-1]) continue;
dfs2(nv);
}
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v)
{
n=a.size();
ans.resize(n);
m=u.size();
for(int i=0; i<n; i++) if(r[i]) isC[i+1]=1;
for(int i=0; i<m; i++)
{
gr[u[i]].push_back(v[i]);
rev_gr[v[i]].push_back(u[i]);
}
for(int i=1; i<=n; i++)
{
if(isC[i])
{
dfs(i);
if(!used[i]) isC[i]=0;
memset(used, 0, sizeof(used));
}
}
for(int i=1; i<=n; i++)
{
if(isC[i]) dfs2(i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
84 ms |
2524 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
924 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
3364 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
556 ms |
2600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
3040 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
84 ms |
2524 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |