Submission #882209

#TimeUsernameProblemLanguageResultExecution timeMemory
882209kokoueEvacuation plan (IZhO18_plan)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int n,m,k,q; int npp[100001]; bool is_npp[100001]; vector<pair<int,int>> edges[100001]; //int sp[10000]; vector<int> sp(100001,INT_MAX); int furthest[100001][100001]; void dijkstra(int start) { // printf("Dijkstra %d: ",start); priority_queue<pair<int,int>> q; vector<int> dist(n+1,INT_MAX); q.push({0,start}); dist[start]=0; sp[start]=0; while(!q.empty()) { // printf("in while: %d->%d \n",q.top().second,q.top().first); int curr=q.top().second; int currDist=-q.top().first; q.pop(); if(dist[curr]<currDist) continue; for(auto edge:edges[curr]) { int next=edge.first; int weight=edge.second; if(dist[curr]+weight<dist[next]) { dist[next]=dist[curr]+weight; sp[next]=min(sp[next],dist[next]); q.push({-dist[next],next}); } } } /* printf("Dijkstra %d: ",start); for(int i=0;i<=n;i++) { printf("%d:%d ",i,dist[i]); } printf("\n"); */ } int dijkstra(int start,int finish) { // printf("Dijkstra %d->%d: ",start,finish); priority_queue<pair<int,int>> q; vector<int> away(n+1,0); q.push({sp[start],start}); away[start]=sp[start]; while(!q.empty()) { // printf("in while: %d->%d \n",q.top().second,q.top().first); int curr=q.top().second; int currAway=q.top().first; q.pop(); if(away[curr]>currAway) continue; for(auto edge:edges[curr]) { int next=edge.first; int len=sp[next]; if(away[next]<min(len,away[curr])) { away[next]=min(len,away[curr]); q.push({away[next],next}); } } } for(int i=1;i<=n;i++) { if(away[i]!=0) furthest[start][i]=away[i]; } /* printf("Dijkstra %d->%d: ",start,finish); for(int i=0;i<=n;i++) { printf("%d:%d ",i,away[i]); } printf("\n"); */ return away[finish]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; // fill_n(a,INT_MAX,n+1); int ai,bi,wi; for(int i=0;i<m;i++) { cin>>ai>>bi>>wi; edges[ai].push_back({bi,wi}); edges[bi].push_back({ai,wi}); } cin>>k; for(int i=0;i<k;i++) { cin>>npp[i]; is_npp[npp[i]]=true; dijkstra(npp[i]); } cin>>q; int si,ti; for(int i=0;i<q;i++) { cin>>si>>ti; if(is_npp[si] || is_npp[ti]) {printf("0\n");continue;} if(furthest[si][ti]) {printf("%d\n",furthest[si][ti]);continue;} if(furthest[ti][si]) {printf("%d\n",furthest[ti][si]);continue;} printf("%d\n",dijkstra(si,ti)); } /* for(int i=0;i<=n;i++) { printf("%d ",sp[i]); }*/ }

Compilation message (stderr)

/tmp/ccoLtIby.o: in function `__tcf_0':
plan.cpp:(.text+0x189): relocation truncated to fit: R_X86_64_PC32 against symbol `edges' defined in .bss section in /tmp/ccoLtIby.o
/tmp/ccoLtIby.o: in function `dijkstra(int, int)':
plan.cpp:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x2ab): relocation truncated to fit: R_X86_64_PC32 against symbol `sp' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x2eb): relocation truncated to fit: R_X86_64_PC32 against symbol `edges' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x302): relocation truncated to fit: R_X86_64_PC32 against symbol `sp' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x36d): relocation truncated to fit: R_X86_64_PC32 against symbol `sp' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x44a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x51e): relocation truncated to fit: R_X86_64_PC32 against symbol `sp' defined in .bss section in /tmp/ccoLtIby.o
/tmp/ccoLtIby.o: in function `dijkstra(int)':
plan.cpp:(.text+0x5ce): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x69e): relocation truncated to fit: R_X86_64_PC32 against symbol `edges' defined in .bss section in /tmp/ccoLtIby.o
plan.cpp:(.text+0x6cb): 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