Submission #678318

#TimeUsernameProblemLanguageResultExecution timeMemory
678318hello_there_123Jakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int,int> >v[300005]; int sto[30005][30005]; priority_queue<pair<int,int>,vector<pair<int,int> >, greater<pair<int,int> > >pq; main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin>>N>>M; for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) sto[i][j] = 1e9; bool occ[N+3]; memset(occ,0,sizeof(occ)); vector<pair<int,int> >hi; for(int i=0;i<M;i++){ int a,b; cin>>a>>b; occ[a] = 1; hi.push_back(make_pair(a,b)); } for(int i=0;i<M;i++){ int x = 1; while(hi[i].first-x*hi[i].second>=0){ //if(occ[hi[i].first-x*hi[i].second])v[hi[i].first].push_back(make_pair(hi[i].first-x*hi[i].second,x)); if(occ[hi[i].first-x*hi[i].second])sto[hi[i].first][hi[i].first-x*hi[i].second] = min(sto[hi[i].first][hi[i].first-x*hi[i].second],x); x++; } x = 1; while(hi[i].first+x*hi[i].second<N){ //if(occ[hi[i].first+x*hi[i].second])v[hi[i].first].push_back(make_pair(hi[i].first+x*hi[i].second,x)); if(occ[hi[i].first+x*hi[i].second])sto[hi[i].first][hi[i].first+x*hi[i].second] = min(sto[hi[i].first][hi[i].first+x*hi[i].second],x); x++; } } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ if(sto[i][j]!=1e9) v[i].push_back(make_pair(j,sto[i][j])); } } pq.push(make_pair(0,hi[0].first)); int dist[300005]; for(int i=0;i<300004;i++) dist[i] = 1e9; dist[hi[0].first] = 0; while(!pq.empty()){ int dis = pq.top().first; int no = pq.top().second; pq.pop(); if(dist[no]<dis)continue; for(pair<int,int>p:v[no]){ if(dis+p.second<dist[p.first]){ dist[p.first] = dis+p.second; pq.push(make_pair(dis+p.second,p.first)); } } } if(dist[hi[1].first] == 1e9) cout<<"-1"; else cout<<dist[hi[1].first]; }

Compilation message (stderr)

skyscraper.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
/tmp/cchbdQ1I.o: in function `__tcf_0':
skyscraper.cpp:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cchbdQ1I.o
/tmp/cchbdQ1I.o: in function `main':
skyscraper.cpp:(.text.startup+0x45): 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/10/libstdc++.a(globals_io.o)
skyscraper.cpp:(.text.startup+0x5c): 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/10/libstdc++.a(globals_io.o)
skyscraper.cpp:(.text.startup+0x1b3): 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/10/libstdc++.a(globals_io.o)
skyscraper.cpp:(.text.startup+0x2fb): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cchbdQ1I.o
skyscraper.cpp:(.text.startup+0x473): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cchbdQ1I.o
skyscraper.cpp:(.text.startup+0x64c): 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/10/libstdc++.a(globals_io.o)
skyscraper.cpp:(.text.startup+0x694): 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/10/libstdc++.a(globals_io.o)
/tmp/cchbdQ1I.o: in function `_GLOBAL__sub_I_v':
skyscraper.cpp:(.text.startup+0x77b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
skyscraper.cpp:(.text.startup+0x795): relocation truncated to fit: R_X86_64_PC32 against `.bss'
skyscraper.cpp:(.text.startup+0x7a1): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status