제출 #735219

#제출 시각아이디문제언어결과실행 시간메모리
735219myrcella철로 (IOI14_rail)C++17
30 / 100
80 ms4492 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} #include "rail.h" const int maxn = 1e6+10;; int dis0[maxn],dis1[maxn],dis2[maxn]; int mark[maxn]; void findLocation(int N, int first, int location[], int stype[]) { rep(i,0,N) stype[i]=-1; location[0] = first; stype[0] = 1; int pos=1; rep(i,1,N) { int tmp = getDistance(i,0); dis0[i] = tmp; if (dis0[i]<dis0[pos]) pos=i; } location[pos] = first + dis0[pos]; memset(mark,-1,sizeof(mark)); mark[location[0]] = 1; stype[pos] = 2; rep(i,0,N) { if (i==pos) continue; dis1[i] = getDistance(i,pos); } //C in the middle rep(i,1,N) if (i!=pos) if (dis1[i]<dis0[pos]) location[i] = location[pos] - dis1[i], stype[i] = 1, mark[location[i]] =1; vector <pii> lft,rit; rep(i,1,N) if (stype[i]==-1) { if (dis0[i] > dis1[i]) lft.pb({dis1[i],i}); else rit.pb({dis0[i],i}); } sort(ALL(lft)); int cmin = 0; for (auto itt:lft) { int it = itt.se; int hi = getDistance(it,cmin); // debug(hi);debug(dis1[it]); int tmp = dis1[cmin] + hi - dis1[it]; tmp/=2; // debug(location[cmin]+tmp); if (mark[location[cmin] + tmp]==1) { stype[it] = 2; location[it] = location[cmin] + hi; } else { stype[it] = 1, location[it] = location[pos] - dis1[it]; cmin = it; mark[location[it]] = 1; } } memset(mark,-1,sizeof(mark)); mark[location[pos]] = 1; sort(ALL(rit)); int dmax = pos; for (auto itt:rit) { int it = itt.se; int hi = getDistance(it,dmax); int tmp = dis0[dmax] + hi - dis0[it]; tmp/=2; if (mark[location[dmax] - tmp]==1) { stype[it] = 1; location[it] = location[dmax] - hi; } else { stype[it] = 2, location[it] = first + dis0[it]; dmax = it; mark[location[it]] = 1; } } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...