답안 #516101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516101 2022-01-20T11:22:19 Z tzuyuna 컴퓨터 네트워크 (BOI14_network) C++17
0 / 100
138 ms 7924 KB
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;  
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#include "network.h"

pi dist[1010];

void findRoute (int N, int a, int b) {
    for (int i = 1; i <= N; ++i) {
        if (i != a) dist[i] = pi(ping(a, i), i);
        else dist[i] = pi(-1, i);
    }
    sort(dist + 1, dist + 1 + N);
    int idx = 0;
    for (int i = 1; i <= N; ++i) {
        if (dist[i].si == b) {
            idx = i;
            break;
        }
    }
    int cur = idx;
    vector<int> ans;
    ans.pb(cur);
    for (int i = idx - 1; i >= 1; --i) {
        // dist(a, i) + dist(i, cur) + 1 == dist(a, cur)
        if (dist[i].fi + ping(i, cur) + 1 == dist[cur].fi) {
            ans.pb(i);
            cur = i;
        }
    }
    ans.pop_back();
    reverse(ans.begin(), ans.end());
    for (auto i: ans) {
        travelTo(dist[i].si);
    }
}

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 103 ms 7924 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 6584 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 138 ms 6576 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 88 ms 6644 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -