Submission #245849

#TimeUsernameProblemLanguageResultExecution timeMemory
245849FashoRail (IOI14_rail)C++14
8 / 100
99 ms10884 KiB
#include <bits/stdc++.h> #define N 1000005 #define ll long long int #define MP make_pair #define pb push_back #define ppb pop_back #define sp " " #define endl "\n" #define fi first #define se second #define ii pair<int,int> #define lli pair<ll,ll> #define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) #define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout); #define mod 1000000007 #define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i] #define fo(i,x,y) for(ll i=x;i<=y;i++) #define INF 1000000000005 #define ull unsigned long long int #include "rail.h" using namespace std; ll n,m,ar[N],sum,t,tut[N],a,b,l,r,tutt[N]; lli p[N]; ll calc(int ind) { ind=p[ind].se; ll x=getDistance(ind,tutt[l]); ll y=getDistance(ind,tutt[r]); // cout<<r<<endl; // cout<<x<<sp<<y<<sp; a=l+x; b=r-y; ll tut=fabs(r-a); tut=y-tut; tut/=2; tut=min(a,r)-tut; // cout<<l<<sp<<r<<sp<<x<<sp<<y<<sp<<tut<<endl<<endl; return tut; } void findLocation(int nn, int frst, int location[], int stype[]) { // cout<<endl; n=nn; l=frst; stype[0]=1; location[0]=frst; tut[frst]=1; tutt[frst]=0; fo(i,1,n-1) { p[i].fi=getDistance(0, i); p[i].se=i; } sort(p+1,p+n); r=p[1].fi+frst; tut[r]=2; tutt[r]=1; stype[p[1].se]=2; location[p[1].se]=r; // fo(i,0,n-1) // cout<<p[i].fi<<sp<<p[i].se<<sp<<endl; // cout<<endl; fo(i,2,n-1) { // cout<<i<<sp; ll x=calc(i); // cout<<x<<endl;; // cout<<l<<sp<<r<<sp<<x<<endl; if(tut[x]==2) { tut[b]=1; tutt[b]=p[i].se; l=min(l,b); stype[p[i].se]=1; location[p[i].se]=b; // cout<<"HELLO"<<sp<<b<<endl; } else { tut[a]=2; tutt[a]=p[i].se; r=max(r,a); stype[p[i].se]=2; location[p[i].se]=a; } } // cout<<endl; // fo(i,0,n-1) // cout<<stype[i]<<sp<<location[i]<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...