이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=3e5+5,mod=1e9+7,Inf=1e17;
int t,tree[4*N][2],a[N],b[N],c[N],d[N],n,R;
vector<int>p;
string s;
map<int,int> ind;
void build(int u,int l,int r,int type){
	tree[u][type]=Inf;
	if(l==r) return;
	int mid=(l+r)/2;
	build(2*u,l,mid,type);
	build(2*u+1,mid+1,r,type);
}
void update(int u,int ind,int l,int r,int type,int val){
	if(l>ind || r<ind) return;
	if(l==r) {
		tree[u][type]=min(tree[u][type],val);
		return;
	}
	int mid=(l+r)/2;
	update(2*u,ind,l,mid,type,val);
	update(2*u+1,ind,mid+1,r,type,val);
	tree[u][type]=min(tree[2*u][type],tree[2*u+1][type]);
}
int getans(int u,int start,int end,int l,int r,int type){
	if(l>end || r<start) return Inf;
	if(start<=l && r<=end){
		return tree[u][type];
	}
	int mid=(l+r)/2;
	return min(getans(2*u,start,end,l,mid,type),getans(2*u+1,start,end,mid+1,r,type));
}
 main(){
	// t=1;
	cin>>n>>R;
	p.push_back(1);
	p.push_back(R);
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		p.push_back(a[i]);
		p.push_back(b[i]);
		p.push_back(c[i]);
	}
	sort(p.begin(),p.end());
	int cur = 0;
	for(int i=0;i<p.size();i++){
		if(!i || p[i]!=p[i-1]) cur++;
		ind[p[i]]=cur;
	}
	build(1,1,cur,0);
	update(1,1,1,cur,0,0);
	build(1,1,cur,1);
	update(1,cur,1,cur,1,0);
	int ans = Inf;
	for(int i=1;i<=n;i++){
		int cost1=getans(1,ind[a[i]],ind[b[i]],1,cur,0);
		int costR=getans(1,ind[a[i]],ind[b[i]],1,cur,1);
//		cout<<cost1<<" "<<costR<<endl;
		ans=min(ans,cost1+costR+d[i]);
		update(1,ind[c[i]],1,cur,0,cost1+d[i]);
		update(1,ind[c[i]],1,cur,1,costR+d[i]);
	}
	if(ans==Inf) cout<<-1;
	else cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
pinball.cpp:37:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 |  main(){
      |       ^
pinball.cpp: In function 'int main()':
pinball.cpp:50:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i=0;i<p.size();i++){
      |              ~^~~~~~~~~| # | 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... |