# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
757633 |
2023-06-13T13:44:46 Z |
Rafi22 |
Toy Train (IOI17_train) |
C++14 |
|
21 ms |
1748 KB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;
const int N=5007;
int a[N],r[N];
vector<int>G[N];
vector<int>RG[N];
int ile[N];
bool is[N];
vector<int> who_wins(vector<int>a,vector<int>r,vector<int>U,vector<int>V)
{
int n=sz(a),m=sz(U);
vector<int>ans(n,1);
for(int i=0;i<m;i++)
{
G[U[i]].pb(V[i]);
RG[V[i]].pb(U[i]);
}
while(true)
{
memset(ile,0,sizeof ile);
deque<int>Q;
for(int i=0;i<n;i++) if(r[i]) Q.pb(i);
while(sz(Q)>0)
{
int v=Q[0];
Q.pop_front();
for(auto u:RG[v])
{
if(is[u]) continue;
ile[u]++;
if(a[u]==1||ile[u]==sz(G[u]))
{
is[u]=1;
Q.pb(u);
}
}
}
bool xd=0;
for(int i=0;i<n;i++) if(!is[i]) ans[i]=0;
for(int i=0;i<n;i++)
{
if(!r[i]) continue;
int c=0;
for(auto u:G[i]) if(is[u]) c++;
if(c==0||(a[i]==0&&c!=sz(G[i])))
{
r[i]=0;
xd=1;
break;
}
}
if(!xd) break;
}
return ans;
}
/*
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<int>x=who_wins({0, 1},{1, 0},{0, 0, 1, 1},{0, 1, 0, 1});
for(auto a:x) cout<<a<<" ";
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1108 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 |
468 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1748 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 |
6 ms |
1376 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 |
Correct |
8 ms |
1492 KB |
Output is correct |
2 |
Correct |
8 ms |
1620 KB |
Output is correct |
3 |
Correct |
8 ms |
1620 KB |
Output is correct |
4 |
Correct |
7 ms |
1476 KB |
Output is correct |
5 |
Correct |
2 ms |
596 KB |
Output is correct |
6 |
Correct |
5 ms |
1076 KB |
Output is correct |
7 |
Correct |
5 ms |
1216 KB |
Output is correct |
8 |
Incorrect |
5 ms |
1236 KB |
3rd lines differ - on the 5th token, expected: '0', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1108 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |