CSES - NOI 2024 - Results
Submission details
Task:Anime Shops
Sender:
Submission time:2024-03-06 15:13:41 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

output/ccb2TRIh.o: in function `_GLOBAL__sub_I_d':
code.cpp:(.text.startup+0x338): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status

Code

#include <bits/stdc++.h>
using namespace std;

#define MAXN 100001
#define INF 10e6

int d[MAXN][MAXN];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m, k;
  cin >> n >> m >> k;

  vector<int> shop;

  int c;
  for (int i = 0; i < k; ++i) {
    cin >> c;
    shop.emplace_back(c);
  }

  for (int i = 1; i < n + 1; ++i)
    for (int j = 1; j < n + 1; ++j)
      d[i][j] = INF;

  int a, b;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;

    d[a][b] = 1;
    d[b][a] = 1;
  }

  for (int k = 1; k < n + 1; ++k) {
    for (int i = 1; i < n + 1; ++i) {
      for (int j = 1; j < n + 1; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int dm;
  for (int i = 1; i < n + 1; ++i) {
    dm = INF;
    for (auto s : shop) {
      if (i != s)
        dm = min(dm, d[i][s]);
    }
    cout << (dm == INF ? -1 : dm) << ' ';
  }
}