#include <bits/stdc++.h>
using namespace std;
const int c=5002;
int n, m, db[c], si[c];
bool v[c], ki[c], sol[c];
vector<int> sz[c], inv[c], ans;
queue<int> q;
void solve() {
while(q.size()>0) {
int id=q.front();
q.pop();
if (!v[id]) {
v[id]=1;
for (int i=0; i<inv[id].size(); i++) {
int x=inv[id][i];
db[x]++;
if (!v[x] && (db[x]==si[x] || (db[x]==1 && ki[x]))) q.push(x);
}
}
}
}
vector<int> who_wins(vector<int> f, vector<int> t, vector<int> x, vector<int> y) {
n=f.size(), m=x.size();
for (int i=0; i<m; i++) {
int a=x[i], b=y[i];
sz[a].push_back(b), inv[b].push_back(a);
}
for (int i=0; i<n; i++) si[i]=sz[i].size(), ki[i]=f[i];
for (int i=0; i<n; i++) if (t[i]) q.push(i);
solve();
for (int i=0; i<n; i++) {
if (!v[i]) q.push(i);
v[i]=0, ki[i]=1-ki[i];
}
solve();
for (int i=0; i<n; i++) ans.push_back(!v[i]);
return ans;
}
Compilation message
train.cpp: In function 'void solve()':
train.cpp:15:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for (int i=0; i<inv[id].size(); i++) {
| ~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1152 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1568 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
1280 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1536 KB |
3rd lines differ - on the 4th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1152 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |