Submission #840216

#TimeUsernameProblemLanguageResultExecution timeMemory
840216LibClosing Time (IOI23_closing)C++17
0 / 100
105 ms29640 KiB
#include <closing.h> #include <bits/stdc++.h> using namespace std; //long long U[200003]; //long long V[200003]; //long long W[200003]; int check[200003]; vector <vector <pair <int,int> > > adj; int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vector <pair <int,int> > temp; //int N,X,Y; //long long K; //cin>>N; //cin>>X>>Y>>K; for(int i=0;i<=N;i++){ adj.push_back(temp); } vector <pair <int, int> > clist; vector <long long> dist; for(int i=0;i<N-1;i++){ //cin>>U[i]>>V[i]>>W[i]; adj[U[i]].push_back({V[i],W[i]}); adj[V[i]].push_back({U[i],W[i]}); } int cnt=0; cnt=0; for(int i=0;i<N;i++){ check[i]=0; } clist.push_back({X,0}); dist.push_back(0); check[X]=1; while(cnt<clist.size()){ for(int i=0;i<adj[clist[cnt].first].size();i++){ if(check[adj[clist[cnt].first][i].first]==0){ check[adj[clist[cnt].first][i].first]=1; clist.push_back({adj[clist[cnt].first][i].first,adj[clist[cnt].first][i].second+clist[cnt].second}); dist.push_back(adj[clist[cnt].first][i].second+clist[cnt].second); } } cnt++; }; cnt=0; for(int i=0;i<N;i++){ check[i]=0; } clist.push_back({Y,0}); dist.push_back(0); check[Y]=1; while(cnt<clist.size()){ for(int i=0;i<adj[clist[cnt].first].size();i++){ if(check[adj[clist[cnt].first][i].first]==0){ check[adj[clist[cnt].first][i].first]=1; clist.push_back({adj[clist[cnt].first][i].first,adj[clist[cnt].first][i].second+clist[cnt].second}); dist.push_back(adj[clist[cnt].first][i].second+clist[cnt].second); } } cnt++; } sort(dist.begin(),dist.end()); long long tdist=0;; for(int i=0;i<dist.size();i++){ tdist+=dist[i]; if(tdist>K){ return i; } } } /* 4 0 3 20 0 1 18 1 2 1 2 3 19 */

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:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  while(cnt<clist.size()){
      |        ~~~^~~~~~~~~~~~~
closing.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i=0;i<adj[clist[cnt].first].size();i++){
      |               ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
closing.cpp:51:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  while(cnt<clist.size()){
      |        ~~~^~~~~~~~~~~~~
closing.cpp:52:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   for(int i=0;i<adj[clist[cnt].first].size();i++){
      |               ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
closing.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |  for(int i=0;i<dist.size();i++){
      |              ~^~~~~~~~~~~~
closing.cpp:11:27: warning: control reaches end of non-void function [-Wreturn-type]
   11 |  vector <pair <int,int> > temp;
      |                           ^~~~
#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...