// ~ Be Name Khoda ~ //
#include "train.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 5e3 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
int cnt[maxn5], q[maxn5];
vector <int> adj[maxn5], jda[maxn5], ret, a;
bool good[maxn5][maxn5];
int n, m;
void solve(int x){
for(int i = 0; i < n; i++)
cnt[i] = adj[i].size();
int l = 0, r = 0;
for(auto u : jda[x]){
if(a[u]){
q[r++] = u;
good[x][u] = true;
}
else if(cnt[u] > 1)
cnt[u]--;
else{
q[r++] = u;
good[x][u] = true;
}
}
while(l < r){
int v = q[l++];
for(auto u : jda[v]) if(!good[x][u]){
if(a[u]){
q[r++] = u;
good[x][u] = true;
}
else if(cnt[u] > 1)
cnt[u]--;
else{
q[r++] = u;
good[x][u] = true;
}
}
}
}
std::vector<int> who_wins(std::vector<int> A, std::vector<int> ch, std::vector<int> u, std::vector<int> v) {
a = A;
n = a.size();
m = u.size();
for(int i = 0; i < m; i++){
adj[u[i]].pb(v[i]);
jda[v[i]].pb(u[i]);
cnt[u[i]]++;
}
for(int i = 0; i < n; i++) if(ch[i])
solve(i);
bool found = false;
for(int i = 0; i < n; i++){
bool x = true;
for(int j = 0; j < n; j++) if(ch[j] && good[j][i])
x = false;
if(x)
found = true;
}
for(int i = 0; i < n; i++){
bool re = false;
for(int j = 0; j < n; j++) if(ch[j] && good[j][j] && good[j][i])
re = true;
ret.pb(re || !found);
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
206 ms |
9736 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
552 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
5968 KB |
Output is correct |
2 |
Correct |
140 ms |
9816 KB |
Output is correct |
3 |
Correct |
200 ms |
13252 KB |
Output is correct |
4 |
Correct |
308 ms |
11472 KB |
Output is correct |
5 |
Correct |
97 ms |
4500 KB |
Output is correct |
6 |
Correct |
77 ms |
4812 KB |
Output is correct |
7 |
Correct |
467 ms |
18680 KB |
Output is correct |
8 |
Correct |
39 ms |
1632 KB |
Output is correct |
9 |
Correct |
50 ms |
1560 KB |
Output is correct |
10 |
Correct |
40 ms |
1828 KB |
Output is correct |
11 |
Correct |
37 ms |
1612 KB |
Output is correct |
12 |
Correct |
43 ms |
1552 KB |
Output is correct |
13 |
Correct |
40 ms |
1620 KB |
Output is correct |
14 |
Correct |
40 ms |
1632 KB |
Output is correct |
15 |
Correct |
40 ms |
1632 KB |
Output is correct |
16 |
Correct |
37 ms |
1680 KB |
Output is correct |
17 |
Correct |
37 ms |
1632 KB |
Output is correct |
18 |
Correct |
309 ms |
18604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
397 ms |
4060 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
1628 KB |
Output is correct |
2 |
Correct |
40 ms |
1616 KB |
Output is correct |
3 |
Correct |
39 ms |
1668 KB |
Output is correct |
4 |
Correct |
37 ms |
1540 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
39 ms |
1144 KB |
Output is correct |
7 |
Correct |
4 ms |
1208 KB |
Output is correct |
8 |
Correct |
4 ms |
1236 KB |
Output is correct |
9 |
Correct |
4 ms |
1236 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
5 ms |
1204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
206 ms |
9736 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |