Submission #498302

#TimeUsernameProblemLanguageResultExecution timeMemory
498302aryan12Computer Network (BOI14_network)C++17
100 / 100
83 ms7940 KiB
#include "network.h" #include <bits/stdc++.h> using namespace std; void findRoute (int n, int a, int b) { vector<pair<int, int> > dist; for(int i = 1; i <= n; i++) { if(i != a) { int cur_dist = ping(i, a) + 1; dist.push_back({cur_dist, i}); } } sort(dist.begin(), dist.end()); int pos = 0, dest_pos; for(int i = 0; i < dist.size(); i++) { if(dist[i].second == b) { pos = i; dest_pos = i; break; } } vector<int> ans; ans.push_back(b); for(int i = pos - 1; i >= 0; i--) { int cur_dist = ping(dist[i].second, dist[pos].second) + 1; if(cur_dist == 1 && dist[pos].first - 1 == dist[i].first) { pos = i; ans.push_back(dist[i].second); } } for(int i = ans.size() - 1; i >= 0; i--) { travelTo(ans[i]); } }

Compilation message (stderr)

network.cpp: In function 'void findRoute(int, int, int)':
network.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0; i < dist.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
network.cpp:15:18: warning: variable 'dest_pos' set but not used [-Wunused-but-set-variable]
   15 |     int pos = 0, dest_pos;
      |                  ^~~~~~~~
grader.c: In function 'int main()':
grader.c:48:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     scanf ("%d%d%d%d", &N, &a, &b, &M);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
grader.c:51:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |             scanf("%d", &distance[u][v]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...