Submission #581875

#TimeUsernameProblemLanguageResultExecution timeMemory
581875Koosha_mvAncient Books (IOI17_books)C++14
Compilation error
0 ms0 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=2e6+99; const ll inf=1e15; int n,p[N],vis[N],mx1[N],mx2[N],mn1[N],mn2[N]; ll Max[N],dist[N],dp[N][N]; queue<int> q; vector<int> vec; vector<pair<int,int>> g[N]; ll minimum_walk(vector<int> p, int s) { ll sum=0,ans=0; n=p.size(); int l=n,r=0; f(i,0,n){ sum+=abs(p[i]-i); if(p[i]!=i) minm(l,i),maxm(r,i); } minm(l,s); maxm(r,s); if(l==r) return 0; f(i,l,r+1) vec.pb(p[i]-l); p=vec; n=p.size(); int mx=0; f(i,0,s){ maxm(mx,p[i]); if(mx==i){ ans+=2; l=i+1; } } int mn=n; f_(i,n-1,s+1){ minm(mn,p[i]); if(mn==i){ ans+=2; r=i-1; } } if(l==r) return 0; vec.clear(); f(i,l,r+1) vec.pb(p[i]-l); p=vec; n=p.size(); f(i,0,n){ g[i].pb({p[i],0}); } f_(i,s,1){ g[i].pb({i-1,1}); g[i-1].pb({i,0}); } f(i,s,n-1){ g[i].pb({i+1,1}); g[i+1].pb({i-1,0}); } q.push(s); f(i,0,n) dist[i]=(i==s ? 0 : N); while(q.size()){ int u=q.front(); q.pop(); for(auto p : g[u]){ int v=p.F,w=p.S; if(dist[u]+w<dist[v]){ dist[v]=dist[u]+w; q.push(v); } } } cout<<ans+2ll*dist[0]; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:93:1: warning: control reaches end of non-void function [-Wreturn-type]
   93 | }
      | ^
/tmp/ccv9O3qP.o: in function `minimum_walk(std::vector<int, std::allocator<int> >, int)':
books.cpp:(.text+0x1d9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x2be): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x412): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x447): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x519): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x584): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x5df): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x5f1): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x62d): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x796): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccv9O3qP.o
books.cpp:(.text+0x79d): 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