// ~ 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], cntkeep[maxn5];
vector <int> adj[maxn5], jda[maxn5], ret;
bool mark[maxn5], good[maxn5], keep[maxn5], remo[maxn5][maxn5];
int n, m;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> ch, std::vector<int> u, std::vector<int> v) {
n = a.size();
m = u.size();
for(int i = 0; i < n; i++){
adj[i].clear();
jda[i].clear();
}
ret.clear();
memset(mark, false, sizeof mark);
memset(good, false, sizeof good);
memset(keep, false, sizeof keep);
memset(remo, false, sizeof remo);
memset(cnt, 0, sizeof cnt);
for(int i = 0; i < m; i++){
adj[u[i]].pb(v[i]);
jda[v[i]].pb(u[i]);
cnt[u[i]]++;
}
while(true){
int x = -1;
for(int i = 0; i < n; i++){
keep[i] = good[i];
cntkeep[i] = cnt[i];
}
for(int i = 0; i < n; i++) if(!good[i] && ch[i])
x = i;
if(x == -1)
break;
int l = 0, r = 0;
for(auto u : jda[x]) if(!good[u]){
if(a[u]){
q[r++] = u;
good[u] = true;
}
else if(cnt[u] > 1){
cnt[u]--;
remo[u][x] = true;
}
else{
q[r++] = u;
good[u] = true;
}
}
while(l < r){
int v = q[l++];
for(auto u : jda[v]) if(!good[u]){
if(a[u]){
q[r++] = u;
good[u] = true;
}
else if(cnt[u] > 1){
cnt[u]--;
remo[u][v] = true;
}
else{
q[r++] = u;
good[u] = true;
}
}
}
for(int i = 0; i < n; i++){
vector <int> tmp;
for(auto u : adj[i]) if(!remo[i][u])
tmp.pb(u);
adj[i] = tmp;
tmp.clear();
for(auto u : jda[i]) if(!remo[u][i])
tmp.pb(u);
jda[i] = tmp;
}
if(!good[x]){
ch[x] = false;
for(int i = 0; i < n; i++)
good[i] = keep[i];
}
}
for(int i = 0; i < n; i++)
ret.pb(good[i]);
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
311 ms |
25700 KB |
3rd lines differ - on the 22nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
25132 KB |
Output is correct |
2 |
Correct |
9 ms |
25044 KB |
Output is correct |
3 |
Incorrect |
9 ms |
25116 KB |
3rd lines differ - on the 3rd token, expected: '0', found: '1' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
315 ms |
26016 KB |
Output is correct |
2 |
Correct |
693 ms |
26060 KB |
Output is correct |
3 |
Correct |
923 ms |
25992 KB |
Output is correct |
4 |
Correct |
18 ms |
25940 KB |
Output is correct |
5 |
Correct |
210 ms |
25968 KB |
Output is correct |
6 |
Correct |
415 ms |
25940 KB |
Output is correct |
7 |
Correct |
25 ms |
25952 KB |
Output is correct |
8 |
Correct |
19 ms |
25940 KB |
Output is correct |
9 |
Correct |
15 ms |
25940 KB |
Output is correct |
10 |
Correct |
23 ms |
25940 KB |
Output is correct |
11 |
Correct |
18 ms |
25940 KB |
Output is correct |
12 |
Correct |
26 ms |
25864 KB |
Output is correct |
13 |
Correct |
17 ms |
25960 KB |
Output is correct |
14 |
Correct |
17 ms |
26000 KB |
Output is correct |
15 |
Correct |
17 ms |
25940 KB |
Output is correct |
16 |
Correct |
17 ms |
25940 KB |
Output is correct |
17 |
Correct |
17 ms |
25940 KB |
Output is correct |
18 |
Correct |
1489 ms |
25804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1844 ms |
25780 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
25940 KB |
Output is correct |
2 |
Correct |
16 ms |
25940 KB |
Output is correct |
3 |
Correct |
16 ms |
26024 KB |
Output is correct |
4 |
Correct |
16 ms |
25900 KB |
Output is correct |
5 |
Correct |
11 ms |
25164 KB |
Output is correct |
6 |
Correct |
13 ms |
25556 KB |
Output is correct |
7 |
Correct |
13 ms |
25644 KB |
Output is correct |
8 |
Correct |
13 ms |
25684 KB |
Output is correct |
9 |
Correct |
13 ms |
25684 KB |
Output is correct |
10 |
Correct |
11 ms |
25288 KB |
Output is correct |
11 |
Correct |
13 ms |
25616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
311 ms |
25700 KB |
3rd lines differ - on the 22nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |