제출 #931064

#제출 시각아이디문제언어결과실행 시간메모리
931064shenfe1철로 (IOI14_rail)C++17
100 / 100
68 ms5052 KiB
#include<bits/stdc++.h> #include "rail.h" using namespace std; #define F first #define S second #define ll long long #define maksim gay // #define int ll #define pb push_back #define sz(s) (int)s.size() #define pii pair<int,int> #define all(v) v.begin(),v.end() #define mem(a,i) memset(a,i,sizeof(a)) #define in insert #define lb lower_bound #define ub upper_bound #define y1 yy #define ppb pop_back const int MAX=2e6+10; const int inf=2e9; const int N=2e5; const int mod=998244353; int binpow(int a,int n){ if(n==0)return 1; if(n%2)return a*binpow(a,n-1)%mod; int k=binpow(a,n/2); return k*k%mod; } int d[MAX]; int use[MAX]; int d1[MAX]; int d2[MAX]; void findLocation(int n, int first, int location[], int stype[]) { int fin=-1; int st=0; for(int i=0;i<n;i++){ stype[i]=0; if(i==st)continue; d[i]=getDistance(st,i); if(fin==-1||d[fin]>d[i])fin=i; } location[0]=first; stype[0]=1; if(n==1)return; for(int i=0;i<n;i++){ if(i==fin)continue; d1[i]=getDistance(fin,i); } location[fin]=first+d[fin]; stype[fin]=2; vector<pii> vec,vec1; for(int i=0;i<n;i++){ if(i==st||i==fin)continue; if(d[i]==d[fin]+d1[i]){ vec.pb({d[i],i}); } else{ vec1.pb({d1[i],i}); } } sort(all(vec)); int last=st; vector<pii> Op; // Op.pb({location[st],st}); int lo=-1; for(auto [ff,v]:vec){ if(lo==-1){ stype[v]=1; location[v]=location[fin]-d1[v]; lo=v; Op.pb({location[v],v}); continue; } int dd=getDistance(v,lo); // cout<<v<<" "<<dd<<"\n"; bool ok=0; for(auto [dv,u]:Op){ // cout<<d[v]<<" "<<d[u]<<" "<<dd<<"\n"; if(d[v]==d[u]+dd-(location[u]-location[lo])){ location[v]=location[lo]+dd; stype[v]=2; ok=1; break; } } if(!ok){ stype[v]=1; location[v]=location[fin]-d1[v]; lo=v; Op.pb({location[v],v}); } } sort(all(vec1)); Op.clear(); lo=-1; for(auto [ff,v]:vec1){ if(lo==-1){ stype[v]=2; location[v]=location[st]+d[v]; lo=v; Op.pb({location[v],v}); continue; } int dd=getDistance(v,lo); bool ok=0; for(auto [dv,u]:Op){ if(d[v]==d[u]+dd+(location[u]-location[lo])){ location[v]=location[lo]-dd; stype[v]=1; ok=1; break; } } if(!ok){ stype[v]=2; location[v]=location[st]+d[v]; lo=v; Op.pb({location[v],v}); } } }

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:70:7: warning: unused variable 'last' [-Wunused-variable]
   70 |   int last=st;
      |       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...