Submission #980120

#TimeUsernameProblemLanguageResultExecution timeMemory
980120FZ_MeloClosing Time (IOI23_closing)C++17
0 / 100
76 ms20564 KiB
#include "closing.h" #include <bits/stdc++.h> #include <vector> #include <queue> using namespace std; struct ari{ int node; long long w; }; struct tpos{ int node; long long cnt; }; bool operator <(const tpos &a, const tpos &b){ return a.cnt>b.cnt; } int n; long long k; long long cnt; int ans; vector<vector<ari>> adj; priority_queue<tpos> q; void dfs(){ tpos t, ta; while(!q.empty() && cnt<k){ t=q.top(); q.pop(); if(cnt+t.cnt<=k) cnt+=t.cnt; else break; ans++; for(auto h: adj[t.node]){ q.push({h.node, t.cnt+h.w}); } } } int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n=N; k=K; ans=2; adj.resize(n); for(int i=0; i<n-1; i++){ adj[U[i]].push_back({V[i], W[i]}); adj[V[i]].push_back({U[i], W[i]}); } for(int i=0; i<adj[X].size(); i++){ q.push({adj[X][i].node, adj[X][i].w}); } for(int i=0; i<adj[X].size(); i++){ q.push({adj[X][i].node, adj[X][i].w}); } dfs(); return ans; }

Compilation message (stderr)

closing.cpp: In function 'void dfs()':
closing.cpp:30:13: warning: unused variable 'ta' [-Wunused-variable]
   30 |     tpos t, ta;
      |             ^~
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ari>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0; i<adj[X].size(); i++){
      |                  ~^~~~~~~~~~~~~~
closing.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ari>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0; i<adj[X].size(); i++){
      |                  ~^~~~~~~~~~~~~~
#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...