#include "train.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn=5005;
int n, m;
vector < int > ms[maxn];
int charge[maxn];
bool tko[maxn];
bool bio[maxn];
vector < int > sol;
int dfs(int x){
if(bio[x]){
return sol[x];
}
bio[x]=1;
if(find(ms[x].begin(), ms[x].end(), x)!=ms[x].end()){
if(tko[x]==charge[x]){
return sol[x]=charge[x];
}
if(ms[x].size()==1){
return sol[x]=charge[x];
}
if(ms[x][0]==x){
swap(ms[x][0], ms[x][1]);
}
}
return sol[x]=dfs(ms[x][0]);
}
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<n; i++){
tko[i]=a[i];
charge[i]=r[i];
}
for(int i=0; i<m; i++){
ms[u[i]].push_back(v[i]);
}
sol.resize(n, 0);
for(int i=0; i<n; i++){
if(!bio[i]){
dfs(i);
}
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
824 KB |
Output is correct |
2 |
Correct |
5 ms |
828 KB |
Output is correct |
3 |
Correct |
6 ms |
804 KB |
Output is correct |
4 |
Correct |
5 ms |
820 KB |
Output is correct |
5 |
Correct |
4 ms |
800 KB |
Output is correct |
6 |
Correct |
5 ms |
828 KB |
Output is correct |
7 |
Correct |
6 ms |
844 KB |
Output is correct |
8 |
Correct |
5 ms |
824 KB |
Output is correct |
9 |
Correct |
6 ms |
844 KB |
Output is correct |
10 |
Correct |
7 ms |
820 KB |
Output is correct |
11 |
Correct |
5 ms |
816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
400 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1324 KB |
Output is correct |
2 |
Correct |
11 ms |
1324 KB |
Output is correct |
3 |
Correct |
10 ms |
1324 KB |
Output is correct |
4 |
Incorrect |
10 ms |
1164 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1068 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
1228 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
824 KB |
Output is correct |
2 |
Correct |
5 ms |
828 KB |
Output is correct |
3 |
Correct |
6 ms |
804 KB |
Output is correct |
4 |
Correct |
5 ms |
820 KB |
Output is correct |
5 |
Correct |
4 ms |
800 KB |
Output is correct |
6 |
Correct |
5 ms |
828 KB |
Output is correct |
7 |
Correct |
6 ms |
844 KB |
Output is correct |
8 |
Correct |
5 ms |
824 KB |
Output is correct |
9 |
Correct |
6 ms |
844 KB |
Output is correct |
10 |
Correct |
7 ms |
820 KB |
Output is correct |
11 |
Correct |
5 ms |
816 KB |
Output is correct |
12 |
Incorrect |
1 ms |
400 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |