#include <bits/stdc++.h>
#include "closing.h"
using namespace std;
#define int long long
#define sz(a){ return (int)a.size(); }
const int INF=1e9;
vector<vector<pair<int,int>>> edges;
vector<int> dstX;
vector<int> dstY;
signed max_score(signed N, signed rootX, signed rootY, long long K, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W){
vector<pair<int,int>> singl;
vector<pair<int,int>> doubl;
edges.clear();
dstX.clear();
edges.resize(N);
dstX.resize(N);
dstY.resize(N);
singl.resize(N);
doubl.resize(N);
for (int i = 0; i < N-1; i++)
{
edges[V[i]].push_back({U[i], W[i]});
edges[U[i]].push_back({V[i], W[i]});
}
if(rootX>rootY) swap(rootX, rootY);
vector<bool> visited(N);
queue<pair<int,int>> queue;
queue.push({rootX,0});
while(!queue.empty()){
int x=queue.front().first,w=queue.front().second; queue.pop();
if(visited[x]) continue;
visited[x]=true;
dstX[x]=w;
for (auto u: edges[x]) queue.push({u.first, u.second+w});
}
visited.clear();
visited.resize(N);
queue.push({rootY,0});
while(!queue.empty()){
int x=queue.front().first,w=queue.front().second; queue.pop();
if(visited[x]) continue;
visited[x]=true;
dstY[x]=w;
for (auto u: edges[x]) queue.push({u.first, u.second+w});
}
int mx=0;
for (int l1 = rootX; l1 >= 0; l1--)
{
for (int r1 = rootX; r1 < N; r1++)
{
for (int l2 = rootY; l2 >= 0; l2--)
{
for (int r2 = rootY; r2 < N; r2++)
{
int sum=0;
for (int i = 0; i < N; i++)
{
if(l1<=i&&r1>=i) sum+=max(dstX[i],dstY[i]);
else if(l1<=i&&r1>=i) sum+=dstX[i];
else if(l2<=i&&r2>=i) sum+=dstY[i];
}
if(sum>K) continue;
//cerr << l1 << " " << r1 << " " << l2 << " " << r2 << "\n";
mx=max((r1-l1)+(r2-l2)+2,mx);
}
}
}
}
return (int)mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1061 ms |
32916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
436 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '34', found: '19' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
436 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '34', found: '19' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
436 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '34', found: '19' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |