답안 #445449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445449 2021-07-18T04:15:02 Z blue 컴퓨터 네트워크 (BOI14_network) C++17
50 / 100
106 ms 7892 KB
#include "network.h"
#include <vector>
#include <iostream>
using namespace std;

int getDist(int x, int y)
{
    if(x == y) return 0;
    else
    {
        int P = ping(x, y);
        // cerr << "returning " << P << " for " << x << ", " << y << "\n";
        return P + 1;
    }
}

void findRoute(int N, int a, int b)
{
    int distA[N+1];
    for(int i = 1; i <= N; i++) distA[i] = getDist(a, i);

    vector<int> dist_list[N+1];
    for(int i = 1; i <= N; i++)
    {
        dist_list[ distA[i] ].push_back(i);
    }


    for(int x = 1; x <= distA[b]; x++)
    {
        // cerr << "x = " << x << '\n';
        for(int A:dist_list[ distA[a] + 1 ])
        {
            if(distA[a] + getDist(a, A) + getDist(A, b) == distA[b])
            {
                // cerr << "travelling to " << A << '\n';
                travelTo(A);
                a = A;
                break;
            }
        }
    }
}

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]
   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]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 4420 KB Too many calls to ping
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 4504 KB Output is correct
2 Correct 24 ms 2760 KB Output is correct
3 Correct 100 ms 7756 KB Output is correct
4 Correct 100 ms 6212 KB Output is correct
5 Correct 98 ms 7864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 4352 KB Output is correct
2 Correct 24 ms 2756 KB Output is correct
3 Correct 101 ms 7776 KB Output is correct
4 Correct 94 ms 6208 KB Output is correct
5 Correct 100 ms 7892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 95 ms 4380 KB Too many calls to ping
2 Halted 0 ms 0 KB -