Submission #206680

# Submission time Handle Problem Language Result Execution time Memory
206680 2020-03-04T12:49:08 Z PeppaPig Computer Network (BOI14_network) C++14
50 / 100
143 ms 4728 KB
#include "network.h"
#include <bits/stdc++.h>

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

const int N = 1e3+5;

map<pii, int> mp;

int get_dist(int a, int b) {
    if(a == b) return 0;
    else if(mp.count(pii(a, b))) return mp[pii(a, b)];
    else return mp[pii(a, b)] = mp[pii(b, a)] = ping(a, b) + 1;
}

int len;
vector<int> dist[N];

void findRoute (int n, int a, int b) {
    for(int i = 1; i <= n; i++) if(i != a) {
        int now = get_dist(a, i);
        dist[now].emplace_back(i);
        if(i == b) len = now;
    }
    int pre = a;
    for(int i = 1; i < len; i++) for(int x : dist[i])
        if(get_dist(pre, x) == 1 && i + get_dist(x, b) == len) {
            travelTo(x);
            pre = x;
            break;
        }
    travelTo(b);
}

Compilation message

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]
     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]
             scanf("%d", &distance[u][v]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 4604 KB Too many calls to ping
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 120 ms 4472 KB Output is correct
2 Correct 35 ms 2436 KB Output is correct
3 Correct 137 ms 4572 KB Output is correct
4 Correct 106 ms 4476 KB Output is correct
5 Correct 137 ms 4664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 4472 KB Output is correct
2 Correct 32 ms 2424 KB Output is correct
3 Correct 143 ms 4728 KB Output is correct
4 Correct 109 ms 4472 KB Output is correct
5 Correct 135 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 4600 KB Output is correct
2 Correct 47 ms 2552 KB Output is correct
3 Incorrect 137 ms 4600 KB Too many calls to ping
4 Halted 0 ms 0 KB -