#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vpl vector<pll>
const int N=2e5+10;
vpl ma[N];
ll paid[N],dist[N][2];
bool vis[N][2];
// ll dist_[2][N];
int max_score(int n, int x, int y, long long k, std::vector<int> U,std::vector<int> V, std::vector<int> W)
{
for(int i=0;i<=n;i++)
{
ma[i].clear();
paid[i]=0;
vis[i][0]=vis[i][1]=0;
dist[i][0]=dist[i][1]=1e18+10;
}
int m=U.size();
for(int i=0;i<m;i++)
{
ma[U[i]].push_back({W[i],V[i]});
ma[V[i]].push_back({W[i],U[i]});
}
priority_queue<ppll,vector<ppll>,greater<ppll>> pq;
pq.push({0,{0,x}});
pq.push({0,{1,y}});
dist[x][0]=0;
dist[y][1]=0;
ll cur=0;
while(pq.size()>0)
{
ppll it=pq.top();
pq.pop();
int u=it.second.second;
ll c=it.first;
int origin=it.second.first;
if(c!=dist[u][origin] or vis[u][origin])continue;
c-=paid[u];
c=max(0ll,c);
if((cur+c)>k)
continue;
cur+=c;
paid[u]+=c;
vis[u][origin]=1;
for(auto [w,v]:ma[u])
{
if(dist[v][origin]>(c+w))
{
dist[v][origin]=c+w;
pq.push({c+w,{origin,v}});
}
}
}
int total=0;
for(int i=0;i<n;i++)
{
total+=vis[i][0];
total+=vis[i][1];
}
return total;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
25168 KB |
Output is correct |
2 |
Correct |
60 ms |
28380 KB |
Output is correct |
3 |
Correct |
38 ms |
14676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Correct |
2 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Correct |
2 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Correct |
2 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Correct |
2 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Correct |
2 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9820 KB |
1st lines differ - on the 1st token, expected: '30', found: '40' |
4 |
Halted |
0 ms |
0 KB |
- |