Submission #844666

#TimeUsernameProblemLanguageResultExecution timeMemory
844666oneloveforeverClosing Time (IOI23_closing)C++17
0 / 100
84 ms20584 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; #define x first #define y second #define ii pair<int,int> int n,a,b,k; vector<vector<ii> >edge; int Sub1() { queue<int>q; vector<vector<int> >dist(2,vector<int>(n+1,-1)); vector<int>source(2); source[0]=a; source[1]=b; for(int i=0;i<=1;i++) { queue<int>q; q.push(source[i]); dist[i][source[i]]=0; while(!q.empty()) { int x=q.front(); q.pop(); for(ii need:edge[x]) { int node=need.x; int value=need.y; if(dist[i][node]==-1) { dist[i][node]=dist[i][x]+value; q.push(node); } } } } if(dist[0][source[1]]<2*k)return -1; priority_queue<int,vector<int>,greater<int> >p; for(int i=1;i<=n;i++) { if(dist[0][i]<=k)p.push(dist[0][i]); if(dist[1][i]<=k)p.push(dist[1][i]); } int res=k; int ans=0; while(!p.empty()) { int x=p.top(); p.pop(); if(res<x)break; res-=x; ans++; } return ans; } int max_score(int N,int X,int Y,long long K,vector<int>U,vector<int>V,vector<int>W) { n=N; a=X+1; b=Y+1; k=K; edge.resize(n+1); for(int i=1;i<=N-1;i++) { int x=U[i-1]+1; int y=V[i-1]+1; int value=W[i-1]; edge[x].push_back({y,value}); edge[y].push_back({x,value}); } int value=Sub1(); if(value!=-1)return value; }

Compilation message (stderr)

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...