이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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],xx[N];
lli p[N];
ll calc(int ind)
{
ll tutmac=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;
// if(tutmac==2)
// cout<<"[d] "<<tutt[r]<<sp<<p[1].se<<endl;
a=l+x;
b=r-y;
ll tut=fabs(r-a);
tut=y-tut;
tut/=2;
tut=min(a,r)-tut;
// if(tutmac==2)
// cout<<r<<sp<<a<<sp<<tut<<sp;
// if(tutmac==2)
// cout<<x<<sp<<y<<endl;
// cout<<l<<sp<<r<<sp<<x<<sp<<y<<sp<<tut<<endl<<endl;
return tut;
}
ll calc2(int ind)
{
ll tutmac=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;
// if(tutmac==2)
// cout<<r<<sp<<a<<sp<<tut<<sp;
// if(tutmac==2)
// cout<<x<<sp<<y<<endl;
// 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]=p[1].se;
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);
xx[i]=x;
if(i==2)
cout<<x<<endl;
// 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;
continue;
}
// if(i==1)
else
{
tut[a]=2;
tutt[a]=p[i].se;
r=max(r,a);
stype[p[i].se]=2;
location[p[i].se]=a;
continue;
}
calc2(i);
if(i==2)
cout<<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;
continue;
}
if(i==1)
{
tut[a]=2;
tutt[a]=p[i].se;
r=max(r,a);
stype[p[i].se]=2;
location[p[i].se]=a;
continue;
}
}
// cout<<endl;
// fo(i,0,n)
// {
// ll ind=p[i].se;
// // cout<<xx[i]<<endl;
// if(stations[ind].location!=location[ind] || stations[ind].type!=stype[ind])
// {
// cout<<"HELLO"<<sp;
// cout<<i<<sp<<p[i].se<<endl;
// cout<<stations[ind].location<<sp<<stations[ind].type<<sp<<sp<<location[ind]<<sp<<stype[ind]<<endl;
// break;
// }
// }
// fo(i,0,n-1)
// cout<<stype[i]<<sp<<location[i]<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'long long int calc(int)':
rail.cpp:27:8: warning: unused variable 'tutmac' [-Wunused-variable]
ll tutmac=ind;
^~~~~~
rail.cpp: In function 'long long int calc2(int)':
rail.cpp:51:8: warning: unused variable 'tutmac' [-Wunused-variable]
ll tutmac=ind;
^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |