#include "train.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
typedef vector<int> vi;
const int MAXN = 5001;
struct LineSolve {
vi a, r, u, v;
int n, m;
vector <int> g[MAXN];
vector <int> rg[MAXN];
LineSolve (vi A, vi R, vi U, vi V) {
a = A;
r = R;
u = U;
v = V;
n = szof(a);
m = szof(u);
for (int i = 0; i < m; i++) {
g[u[i]].push_back(v[i]);
rg[v[i]].push_back(u[i]);
}
}
void solve(vector <int> &ans) {
vector <bool> used(MAXN, false);
vector <int> ends;
for (int i = 0; i < m; i++) {
if (u[i] == v[i]) {
ends.push_back(u[i]);
}
}
for (int x : ends) {
vector <int> path = {};
int answer = r[x];
ans[x] = answer;
if (szof(rg[x]) == 2) {
int v =(rg[x][0] == x ? rg[x][1] : rg[x][0]);
while(1) {
ans[v] = answer;
if (szof(rg[v]) == 0) {
break;
}
v = rg[v][0];
}
}
}
}
};
vi who_wins(vi a, vi r, vi u, vi v) {
vi res(a.size(), -1);
LineSolve subtask1(a, r, u, v);
subtask1.solve(res);
return res;
}
//signed main() {
//}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
1280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2082 ms |
512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2013 ms |
2048 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2067 ms |
1664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
1920 KB |
3rd lines differ - on the 1st token, expected: '1', found: '-1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
1280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |