Submission #695241

#TimeUsernameProblemLanguageResultExecution timeMemory
695241NeroZeinJakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 300003;; int n, m; int b[N]; int p[N]; int g[N][N]; inline void minSelf(int& x, int y) { x = min(x, y); } int cost[N]; inline void dij() { priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq; for (int i = 0; i < n; ++i) { cost[i] = 1e15; } cost[b[0]] = 0; pq.emplace(0, b[0]); while (!pq.empty()) { auto src = pq.top(); pq.pop(); if (src.second == b[1]) { cout << src.first << '\n'; exit(0); } if (src.first != cost[src.second]) { continue; } for (int i = 0; i < n; ++i) { if (src.first + g[src.second][i] < cost[i]) { cost[i] = src.first + g[src.second][i]; pq.emplace(cost[i], i); } } } } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { g[i][j] = 1e15; } } for (int i = 0; i < m; ++i) { cin >> b[i] >> p[i]; for (int j = 1; j < n; ++j) { int l = b[i] - j * p[i]; int r = b[i] + j * p[i]; if (r < n) { minSelf(g[b[i]][r], j); } if (l >= 0) { minSelf(g[b[i]][l], j); } } } dij(); cout << -1 << '\n'; return 0; }

Compilation message (stderr)

/usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(vterminate.o): in function `__gnu_cxx::__verbose_terminate_handler()':
(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x1e): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZZN9__gnu_cxx27__verbose_terminate_handlerEvE11terminating'
(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x2b): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZZN9__gnu_cxx27__verbose_terminate_handlerEvE11terminating'
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status