#include "train.h"
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;
using vi = vector<int>;
#define sz(x) int(x.size())
//a = owner, r = charging
vi who_wins(vi a, vi r, vi U, vi V)
{
int n = sz(a);
int m = sz(U);
vi edge[n];
vi revedge[n];
for(int j = 0; j < m; j++)
{
edge[U[j]].push_back(V[j]);
revedge[V[j]].push_back(U[j]);
}
vi good(n, 0);
vi pushed(n, 0);
queue<int> tbv;
for(int i = 0; i < n; i++)
{
if(r[i])
{
good[i] = 1;
tbv.push(i);
pushed[i] = 1;
}
}
vi deg(n, 0);
for(int j = 0; j < m; j++)
deg[U[j]]++;
// cerr << "done\n";
while(!tbv.empty())
{
int u = tbv.front();
tbv.pop();
// cerr << "u = " << u << '\n';
for(int v : revedge[u])
{
if(pushed[v]) continue;
if(a[v] == 1)
{
pushed[v] = 1;
tbv.push(v);
good[v] = 1;
}
else
{
deg[v]--;
if(deg[v] == 0)
{
pushed[v] = 1;
tbv.push(v);
good[v] = 1;
}
}
}
}
int cs = 0;
while(!r[cs])
cs++;
bool works;
if(a[cs] == 1)
{
works = 0;
for(int v : edge[cs])
if(good[v])
works = 1;
}
else
{
works = 1;
for(int v : edge[cs])
if(!good[v])
works = 0;
}
if(!works) good = vi(n, 0);
return good;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1108 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1592 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1364 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1748 KB |
Output is correct |
2 |
Correct |
8 ms |
1500 KB |
Output is correct |
3 |
Correct |
9 ms |
1616 KB |
Output is correct |
4 |
Correct |
7 ms |
1468 KB |
Output is correct |
5 |
Correct |
1 ms |
308 KB |
Output is correct |
6 |
Correct |
4 ms |
1108 KB |
Output is correct |
7 |
Correct |
5 ms |
924 KB |
Output is correct |
8 |
Correct |
7 ms |
980 KB |
Output is correct |
9 |
Correct |
5 ms |
980 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
4 ms |
928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1108 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |