QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#154934 | #7118. Closing Time | Mohmad_Zaid | 0 | 0ms | 0kb | C++14 | 891b | 2023-09-01 03:36:39 | 2024-04-28 06:40:02 |
Judging History
answer
// #include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<vector<pair<int,int>>>g;
vector<bool>vis;
set<ll>dis;
ll dfs(int p,int v,ll k,ll curr){
for(auto i:g[v]){
if(i.first==p || vis[i.first])continue;
if(i.second+curr>k)break;
vis[i.first]=1;
dis.insert(curr+i.second);
dfs(v,i.first,k,curr+i.second);
}
}
int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W)
{
int n=N;
dis.clear();
vis.resize(n,0);
g.resize(n,vector<pair<int,int>>());
for(int i=0;i<n;i++){
g[U[i]].pb({V[i],W[i]});
g[V[i]].pb({U[i],W[i]});
}
dfs(X,X,K,0);
dfs(Y,Y,K,0);
ll ans=0;
for(auto i:dis){
if(i>K)break;
ans++;
K-=i;
}
return ans+2;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 200000 31011 61157 8517583098 31011 129396 964383 1655 129396 331139 1655 191487 566483 110385 191487 865248 43212 110385 542661 43212 81682 13766 81682 91774 546589 91774 124706 780638 124706 175650 118706 10421 175650 615314 10421 151953 436270 140430 151...
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #4:
score: 0
Runtime Error
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 50 23 25 382806473 0 1 375710 1 2 898637 2 3 10402 3 4 536577 4 5 385023 5 6 71075 6 7 543368 7 8 301497 8 9 174394 9 10 711312 10 11 923006 11 12 675532 12 13 838667 13 14 565729 14 15 979816 15 16 862618 16 17 576015 17 18 177751 18 19 306989 19 20 881492...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Runtime Error
Test #36:
score: 0
Runtime Error
input:
cc61ad56a4797fb3f5c9529f73ce6fcedd85669b 1 4 0 1 9 0 2 2 1 2 3 2 3 3
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #4:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%