Submission #498302

# Submission time Handle Problem Language Result Execution time Memory
498302 2021-12-24T23:29:46 Z aryan12 Computer Network (BOI14_network) C++17
100 / 100
83 ms 7940 KB
#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

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 time Memory Grader output
1 Correct 74 ms 7880 KB Output is correct
2 Correct 74 ms 7320 KB Output is correct
3 Correct 70 ms 6940 KB Output is correct
4 Correct 69 ms 7016 KB Output is correct
5 Correct 74 ms 6708 KB Output is correct
6 Correct 71 ms 6624 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 6664 KB Output is correct
2 Correct 18 ms 2800 KB Output is correct
3 Correct 78 ms 7824 KB Output is correct
4 Correct 62 ms 6116 KB Output is correct
5 Correct 75 ms 7940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 6700 KB Output is correct
2 Correct 20 ms 2752 KB Output is correct
3 Correct 79 ms 7800 KB Output is correct
4 Correct 64 ms 6124 KB Output is correct
5 Correct 83 ms 7928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 6684 KB Output is correct
2 Correct 17 ms 2708 KB Output is correct
3 Correct 78 ms 7788 KB Output is correct
4 Correct 68 ms 6184 KB Output is correct
5 Correct 76 ms 7932 KB Output is correct