Submission #969284

#TimeUsernameProblemLanguageResultExecution timeMemory
969284angelsClosing Time (IOI23_closing)C++17
0 / 100
1043 ms21336 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { int n=N, x=X, y=Y; long long k=K; vector<pair<int, int>>a[n]; for(int i=0; i<n-1; i++) { a[U[i]].push_back({V[i], W[i]}); a[V[i]].push_back({U[i], W[i]}); } int rez=0; int visited[n]; memset(visited, 0, sizeof(visited)); int id=1; for(int i=0; i<n; i++) { queue<pair<int, long long>>q; q.push(make_pair(i, 0)); while(!q.empty()) { pair<int, long long>ww=q.front(); q.pop(); visited[ww.first]=id; if((ww.first==x || ww.first==y) && ww.second<=k) { rez++; break; } if(ww.second>k) continue; for(int i=0; i<a[ww.first].size(); i++) { if(visited[a[ww.first][i].first]!=id) { q.push(make_pair(a[ww.first][i].first, ww.second+a[ww.first][i].second)); } } } id++; } return rez; return 0; }

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:36:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(int i=0; i<a[ww.first].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...