Submission #1347648

#TimeUsernameProblemLanguageResultExecution timeMemory
1347648jumpJakarta Skyscrapers (APIO15_skyscraper)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

int b[30010];
int p[30010];
int adj[30010][30010];
int dist[30010];
signed main() {
	int n,m;
	std::cin >> n >> m;
	int s=0,e=1;
	for(int i=0;i<m;i++){
		std::cin >> b[i] >> p[i];
		if(i==0)s=b[i];
		else if(i==1)e=b[i];
	}
	for(int i=0;i<n;i++){
		dist[i]=1e9;
		for(int j=0;j<n;j++){
			adj[i][j]=1e9;
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			if(std::abs(j-b[i])%p[i]==0){
				adj[b[i]][j]=std::min(adj[b[i]][j],std::abs(j-b[i])/p[i]);
			}
		}
	}
	std::priority_queue<std::pair<int,int>> pq;
	pq.push({-0,s});
	while(!pq.empty()){
		int weight=-pq.top().first;
		int node=pq.top().second;
		pq.pop();
		for(int j=0;j<n;j++){
			if(weight+adj[node][j]<dist[j]){
				dist[j]=weight+adj[node][j];
				pq.push({-(weight+adj[node][j]),j});
			}
		}
	}
	if(dist[e]>=1e9)dist[e]=-1;
	std::cout << dist[e];
}

Compilation message (stderr)

/tmp/ccCQZi1d.o: in function `main':
skyscraper.cpp:(.text.startup+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
skyscraper.cpp:(.text.startup+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccCQZi1d.o
skyscraper.cpp:(.text.startup+0x6e): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccCQZi1d.o
skyscraper.cpp:(.text.startup+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccCQZi1d.o
skyscraper.cpp:(.text.startup+0x16c): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccCQZi1d.o
skyscraper.cpp:(.text.startup+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccCQZi1d.o
skyscraper.cpp:(.text.startup+0x589): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(vterminate.o): in function `__gnu_cxx::__verbose_terminate_handler()':
(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x22): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZZN9__gnu_cxx27__verbose_terminate_handlerEvE11terminating'
(.text._ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x2f): relocation truncated to fit: R_X86_64_PC32 against `.bss._ZZN9__gnu_cxx27__verbose_terminate_handlerEvE11terminating'
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x66): additional relocation overflows omitted from the output
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status