#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 42, INF = 1e9;
bool ch[N];
int n, m, val[N][2];
vector<int> adj[N];
void DFS(int i) {
if(ch[i])
return;
ch[i] = true;
for(int j : adj[i])
DFS(j);
}
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++)
adj[v[i]].push_back(u[i]);
for(int i = 0; i < 2*n; i++) {
//cout << " " << i << '\n';
for(int j = 0; j < n; j++) {
if(a[0] == 1 || (a[0] == 0 && r[j] == 0)) {
int pds = -1;
if(r[j] == 1)
pds += n;
for(int k : adj[j]) {
if(a[0] == 1) {
//cout << k << ' ' << val[k][1 - (i % 2)] << '\n';
val[k][1 - (i % 2)] = max(val[k][1 - (i % 2)], val[j][i % 2] + pds);
//cout << val[k][1 - (i % 2)] << '\n';
} else if(r[k] == 0)
val[k][1 - (i % 2)] = max(val[k][1 - (i % 2)], val[j][i % 2] - pds);
}
}
}
/*for(int j = 0; j < n; j++)
cout << val[j][1 - (i % 2)] << ' ';
cout << '\n';*/
}
int i = 2*n;
/*for(int j = 0; j < n; j++)
cout << val[j][1 - (i % 2)] << ' ';
cout << '\n';*/
for(int j = 0; j < n; j++) {
if(a[0] == 1 || (a[0] == 0 && r[j] == 0)) {
int pds = -1;
if(r[j])
pds += n;
for(int k : adj[j])
if(a[0] == 1) {
if(val[k][1 - (i % 2)] != max(val[k][1 - (i % 2)], val[j][i % 2] + pds)) {
ch[k] = true;
val[k][1 - (i % 2)] = max(val[k][1 - (i % 2)], val[j][i % 2] + pds);
}
} else if(r[k] == 0) {
if(val[k][1 - (i % 2)] != max(val[k][1 - (i % 2)], val[j][i % 2] - pds)) {
ch[k] = true;
val[k][1 - (i % 2)] = max(val[k][1 - (i % 2)], val[j][i % 2] - pds);
}
}
}
}
/*for(int j = 0; j < n; j++)
cout << val[j][(i % 2)] << ' ';
cout << '\n';
for(int j = 0; j < n; j++)
cout << val[j][1 - (i % 2)] << ' ';
cout << '\n';*/
if(a[0] == 0)
for(int j = 0; j < n; j++)
if(ch[j])
for(int k : adj[j])
DFS(k);
vector<int> res(n);
for(int i = 0; i < n; i++)
if(ch[i])
res[i] = 1;
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
537 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1340 ms |
1388 KB |
Output is correct |
2 |
Correct |
1337 ms |
1392 KB |
Output is correct |
3 |
Correct |
1267 ms |
1372 KB |
Output is correct |
4 |
Correct |
1241 ms |
1368 KB |
Output is correct |
5 |
Incorrect |
1295 ms |
1356 KB |
3rd lines differ - on the 73rd token, expected: '1', found: '0' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
137 ms |
1188 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1358 ms |
1364 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
537 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |