#include "train.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (long long x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<ll,ll> pll;
using namespace std;
const int N = 5032;
bitset<N> berese[N], narese[N];
vector<int> A[N];
int col[N];
vector<int> chargs;
int n, m;
bool self[N];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> V, std::vector<int> U) {
n = a.size();
m = V.size();
Loop (i,0,n) {
col[i] = a[i];
if (r[i])
chargs.push_back(i);
}
Loop (i,0,m) {
int v = V[i], u = U[i];
A[v].push_back(u);
}
Loop (i,0,n)
narese[i].set();
Loop (i,0,n) {
if (col[i]) {
for (int j : A[i])
berese[i][j] = 1;
} else {
for (int j : A[i])
narese[i][j] = 0;
}
if (A[i].size() == 1) {
berese[i][A[i][0]] = 1;
narese[i][A[i][0]] = 0;
}
berese[i][i] = 1;
narese[i][i] = 0;
}
// Loop (i,0,n) {
// Loop (j,0,n)
// cout << berese[i][j];
// cout << '\n';
// }
// Loop (i,0,n) {
// Loop (j,0,n)
// cout << narese[i][j];
// cout << '\n';
// }
// cout << '\n';
Loop (k,0,n) Loop (i,0,n) {
if (!narese[i][k]) {
berese[i] &= berese[k];
narese[i] &= narese[k];
}
if (berese[i][k]) {
berese[i] |= berese[k];
narese[i] |= narese[k];
}
}
// Loop (i,0,n) {
// Loop (j,0,n)
// cout << berese[i][j];
// cout << '\n';
// }
// Loop (i,0,n) {
// Loop (j,0,n)
// cout << narese[i][j];
// cout << '\n';
// }
// cout << '\n';
//}
Loop (i,0,n) {
self[i] = 1;
Loop (j,0,n)
self[i] &= narese[i][j] || berese[j][i];
}
vector<int> fans(n);
Loop (i,0,n) {
bool ans = 0;
for (int c : chargs)
ans |= berese[i][c] && self[c];
fans[i] = ans;
}
return fans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
85 ms |
6972 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
122 ms |
7252 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
847 ms |
7128 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
464 ms |
7224 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
85 ms |
6972 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |