#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 5000;
int n, m;
vector<int> g[1 + maxn], rg[1 + maxn];
int own[1 + maxn], charge[1 + maxn];
bool has_self[1 + maxn];
int charged;
bool good[1 + maxn];
bool good_cycle;
void decide() {
for(int i = 1; i <= n; i++) {
if(charge[i]) {
charged = i;
}
}
good[charged] = true;
for(int iter = 1; iter <= n; iter++) {
for(int cur = 1; cur <= n; cur++) {
bool this_good;
if(own[cur] == 1) {
this_good = false;
for(int nei : rg[cur]) {
if(good[nei]) {
this_good = true;
}
}
} else {
this_good = true;
for(int nei : rg[cur]) {
if(!good[nei]) {
this_good = false;
}
}
}
if(this_good) {
good[cur] = true;
if(cur == charged) {
good_cycle = true;
}
}
}
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size();
m = u.size();
for(int i = 0; i < m; i++) {
g[u[i] + 1].pb(v[i] + 1);
rg[v[i] + 1].pb(u[i] + 1);
if(u[i] == v[i]) {
has_self[u[i] + 1] = true;
}
}
for(int i = 1; i <= n; i++) {
own[i] = a[i - 1];
charge[i] = r[i - 1];
}
decide();
vector<int> res(n);
if(good_cycle) {
for(int i = 0; i < n; i++) {
res[i] = good[i + 1];
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
138 ms |
1060 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
1432 KB |
Output is correct |
2 |
Correct |
199 ms |
1416 KB |
Output is correct |
3 |
Correct |
208 ms |
1404 KB |
Output is correct |
4 |
Incorrect |
246 ms |
1380 KB |
3rd lines differ - on the 13th token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
240 ms |
1212 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
300 ms |
1376 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
138 ms |
1060 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |