#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=5e5+10;
vpl ma[N];
ll paid[N],dist[N];
bool vis[N];
// 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<2*n;i++)
{
ma[i].clear();
paid[i]=0;
vis[i]=0;
dist[i]=k+1;
}
int m=U.size();
for(int i=0;i<m;i++)
{
ma[U[i]].push_back({W[i],V[i]});
ma[U[i]+n].push_back({W[i],V[i]+n});
ma[V[i]].push_back({W[i],U[i]});
ma[V[i]+n].push_back({W[i],U[i]+n});
}
set<pll> pq;
pq.insert({0,x});
pq.insert({0,y+n});
dist[x]=0;
dist[y+n]=0;
ll cur=0;
while(pq.size()>0)
{
pll it=*pq.begin();
pq.erase(begin(pq));
int u=it.second;
ll c=it.first;
if(vis[u])continue;
ll og=cur;
cur+=c;
if(u<n)
{
// paid[u+n]+=c;
if(vis[u+n])
cur-=min(c,dist[u+n]);
}
else
{
if(vis[u-n])
cur-=min(c,dist[u-n]);
}
if((cur)>k)
{
cur=og;
continue;
}
vis[u]=1;
for(auto [w,v]:ma[u])
{
ll cop=c+w;
if(dist[v]>(cop))
{
dist[v]=cop;
pq.insert({cop,v});
}
}
}
int total=0;
for(int i=0;i<2*n;i++)
{
total+=vis[i];
}
return total;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
45652 KB |
Output is correct |
2 |
Correct |
134 ms |
45556 KB |
Output is correct |
3 |
Correct |
39 ms |
20820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18268 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
4 ms |
18272 KB |
Output is correct |
6 |
Correct |
4 ms |
18268 KB |
Output is correct |
7 |
Correct |
4 ms |
18264 KB |
Output is correct |
8 |
Correct |
3 ms |
18268 KB |
Output is correct |
9 |
Correct |
4 ms |
18264 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
3 ms |
18104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18268 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
4 ms |
18272 KB |
Output is correct |
6 |
Correct |
4 ms |
18268 KB |
Output is correct |
7 |
Correct |
4 ms |
18264 KB |
Output is correct |
8 |
Correct |
3 ms |
18268 KB |
Output is correct |
9 |
Correct |
4 ms |
18264 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
3 ms |
18104 KB |
Output is correct |
12 |
Correct |
4 ms |
18268 KB |
Output is correct |
13 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18268 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
4 ms |
18272 KB |
Output is correct |
6 |
Correct |
4 ms |
18268 KB |
Output is correct |
7 |
Correct |
4 ms |
18264 KB |
Output is correct |
8 |
Correct |
3 ms |
18268 KB |
Output is correct |
9 |
Correct |
4 ms |
18264 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
3 ms |
18104 KB |
Output is correct |
12 |
Correct |
4 ms |
18268 KB |
Output is correct |
13 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18264 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
3 ms |
18268 KB |
Output is correct |
6 |
Correct |
4 ms |
18272 KB |
Output is correct |
7 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18264 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
3 ms |
18268 KB |
Output is correct |
6 |
Correct |
4 ms |
18272 KB |
Output is correct |
7 |
Correct |
4 ms |
18268 KB |
Output is correct |
8 |
Correct |
4 ms |
18264 KB |
Output is correct |
9 |
Correct |
3 ms |
18268 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
4 ms |
18264 KB |
Output is correct |
12 |
Correct |
3 ms |
18104 KB |
Output is correct |
13 |
Correct |
4 ms |
18268 KB |
Output is correct |
14 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18264 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
3 ms |
18268 KB |
Output is correct |
6 |
Correct |
4 ms |
18272 KB |
Output is correct |
7 |
Correct |
4 ms |
18268 KB |
Output is correct |
8 |
Correct |
4 ms |
18264 KB |
Output is correct |
9 |
Correct |
3 ms |
18268 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
4 ms |
18264 KB |
Output is correct |
12 |
Correct |
3 ms |
18104 KB |
Output is correct |
13 |
Correct |
4 ms |
18268 KB |
Output is correct |
14 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18264 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
3 ms |
18268 KB |
Output is correct |
6 |
Correct |
4 ms |
18272 KB |
Output is correct |
7 |
Correct |
4 ms |
18268 KB |
Output is correct |
8 |
Correct |
4 ms |
18264 KB |
Output is correct |
9 |
Correct |
3 ms |
18268 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
4 ms |
18264 KB |
Output is correct |
12 |
Correct |
3 ms |
18104 KB |
Output is correct |
13 |
Correct |
4 ms |
18268 KB |
Output is correct |
14 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
18264 KB |
Output is correct |
2 |
Correct |
3 ms |
18264 KB |
Output is correct |
3 |
Correct |
3 ms |
18268 KB |
Output is correct |
4 |
Correct |
3 ms |
18268 KB |
Output is correct |
5 |
Correct |
3 ms |
18268 KB |
Output is correct |
6 |
Correct |
4 ms |
18272 KB |
Output is correct |
7 |
Correct |
4 ms |
18268 KB |
Output is correct |
8 |
Correct |
4 ms |
18264 KB |
Output is correct |
9 |
Correct |
3 ms |
18268 KB |
Output is correct |
10 |
Correct |
4 ms |
18264 KB |
Output is correct |
11 |
Correct |
4 ms |
18264 KB |
Output is correct |
12 |
Correct |
3 ms |
18104 KB |
Output is correct |
13 |
Correct |
4 ms |
18268 KB |
Output is correct |
14 |
Incorrect |
3 ms |
18268 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |