#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define pb push_back
#define eb emplace_back
ll distX[200005], distY[200005];
vector<ii> adj[200005];
void get_dist(int u, ll dist[], int e = -1) {
for (auto [v, w] : adj[u]) if (v != e) {
dist[v] = dist[u] + w;
get_dist(v, dist, u);
}
}
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
for (int i = 0; i < N - 1; i++) {
adj[U[i]].eb(V[i], W[i]);
adj[V[i]].eb(U[i], W[i]);
}
get_dist(X, distX);
get_dist(Y, distY);
int ret = 0;
for (int i = X; i >= 0; i--) {
for (int j = X; j < N; j++) {
for (int k = Y; k >= 0; k--) {
for (int l = Y; l < N; l++) {
ll cur = 0;
for (int a = 0; a < N; a++) {
bool cov1 = (i <= a && a <= j);
bool cov2 = (k <= a && a <= l);
if (cov1 && cov2) {
cur += max(distX[a], distY[a]);
} else if (cov1) {
cur += distX[a];
} else if (cov2) {
cur += distY[a];
}
}
if (cur <= K) {
ret = max(ret, j - i + 1 + l - k + 1);
}
}
}
}
}
for (int i = 0; i < N; i++) {
adj[i].clear();
distX[i] = distY[i] = 0;
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6744 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1035 ms |
24656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
30 ms |
6768 KB |
Output is correct |
7 |
Correct |
22 ms |
6748 KB |
Output is correct |
8 |
Correct |
9 ms |
6748 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
30 ms |
6768 KB |
Output is correct |
7 |
Correct |
22 ms |
6748 KB |
Output is correct |
8 |
Correct |
9 ms |
6748 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
116 ms |
6768 KB |
Output is correct |
13 |
Correct |
67 ms |
6748 KB |
Output is correct |
14 |
Correct |
214 ms |
6744 KB |
Output is correct |
15 |
Correct |
91 ms |
6748 KB |
Output is correct |
16 |
Correct |
2 ms |
6744 KB |
Output is correct |
17 |
Correct |
3 ms |
6744 KB |
Output is correct |
18 |
Correct |
8 ms |
6776 KB |
Output is correct |
19 |
Execution timed out |
1037 ms |
6744 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
30 ms |
6768 KB |
Output is correct |
7 |
Correct |
22 ms |
6748 KB |
Output is correct |
8 |
Correct |
9 ms |
6748 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
116 ms |
6768 KB |
Output is correct |
13 |
Correct |
67 ms |
6748 KB |
Output is correct |
14 |
Correct |
214 ms |
6744 KB |
Output is correct |
15 |
Correct |
91 ms |
6748 KB |
Output is correct |
16 |
Correct |
2 ms |
6744 KB |
Output is correct |
17 |
Correct |
3 ms |
6744 KB |
Output is correct |
18 |
Correct |
8 ms |
6776 KB |
Output is correct |
19 |
Execution timed out |
1037 ms |
6744 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6744 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6744 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6744 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6744 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
6744 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |