Submission #120918

#TimeUsernameProblemLanguageResultExecution timeMemory
120918MvCRail (IOI14_rail)C++11
56 / 100
618 ms99576 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> #include "rail.h" #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<62); const int inf=(1<<30); const ll nmax=5e3+50; const int mod=1e9+7; using namespace std; int n,f,i,x,y,j,d[nmax][nmax],mn,s,p,st[nmax]; //int bl[nmax],tp[nmax]; vector<int>l,r; /*int getDistance(int x,int y) { int z; cout<<x<<" "<<y<<endl; cin>>z; return z; }*/ int get(int x,int y) { return getDistance(x,y); } void findLocation(int N,int F,int bl[],int tp[]) { n=N,f=F; bl[0]=f,tp[0]=1; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { d[i][j]=d[j][i]=get(i,j); } } for(i=0;i<n;i++) { mn=1e9; for(j=0;j<n;j++) { if(i==j)continue; if(mn>d[i][j]) { mn=d[i][j]; st[i]=j; } } } s=st[0]; p=st[s]; tp[s]=2,tp[p]=1; bl[s]=bl[0]+d[0][s]; bl[p]=bl[s]-d[s][p]; for(i=0;i<n;i++) { if(i==s || i==p || !i)continue; if(d[s][i]<d[p][i] && st[st[i]]==i)l.pb(i); else if(st[st[i]]==i)r.pb(i); } for(i=0;i<r.size();i++) { x=r[i],y=st[x]; if(d[p][x]<d[p][y] || y==p)swap(x,y); tp[x]=1,tp[y]=2; bl[y]=bl[p]+d[p][y]; bl[x]=bl[y]-d[x][y]; } for(i=0;i<l.size();i++) { x=l[i],y=st[x]; if(d[s][x]<d[s][y] || y==s)swap(x,y); tp[x]=2,tp[y]=1; bl[y]=bl[s]-d[s][y]; bl[x]=bl[y]+d[x][y]; } for(i=0;i<n;i++) { if(tp[i])continue; x=st[i]; if(tp[x]==1) { tp[i]=2; bl[i]=bl[x]+d[x][i]; } else { tp[i]=1; bl[i]=bl[x]-d[x][i]; } } } /*int main() { //freopen("sol.in","r",stdin); //freopen("sol.out","w",stdout); //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); return 0; }*/

Compilation message (stderr)

rail.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
rail.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:71:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<r.size();i++)
          ~^~~~~~~~~
rail.cpp:79:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<l.size();i++)
          ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...