QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234631#6639. Disk Treeugly2333WA 1ms8080kbC++201.3kb2023-11-01 20:02:152023-11-01 20:02:15

Judging History

你现在查看的是最新测评结果

  • [2023-11-01 20:02:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8080kb
  • [2023-11-01 20:02:15]
  • 提交

answer

//Δ_I
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,m,a[N],b[N],c[N];
pair<int,int> p[N*3];
vector<int> v;
set<int> S;
set<int>::iterator it;
int main(){
	int i,j,x,y,o;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d%d",a+i,b+i,c+i);
		p[++m]=make_pair(a[i]-c[i],-i);
		p[++m]=make_pair(a[i]+c[i],i);
		p[++m]=make_pair(a[i]-c[i],0);
	}
	sort(p+1,p+m+1);
	printf("YES\n");
	o=0;
	for(j=1;j<=m;j++){
		i=p[j].second;
		if(i==0){
			if(!v.size())
				continue;
			sort(v.begin(),v.end());
			for(i=0;i<v.size();i++){
				if(v[i]>*S.begin()){
					it=S.lower_bound(v[i]);
					it--;
					printf("%d %d %d %d\n",p[j].first,*it,p[j].first,v[i]);
					S.insert(v[i]);
				}
			}
			for(i=v.size()-1;i>=0;i--){
				if(v[i]<*S.begin()){
					it=S.lower_bound(v[i]);
					printf("%d %d %d %d\n",p[j].first,*it,p[j].first,v[i]);
					S.insert(v[i]);
				}
			}
			v.clear();
			continue;
		}
		if(i<0){
			i=-i;
			if(S.empty()){
				if(o)
					printf("%d %d %d %d\n",x,y,a[i]-c[i],b[i]);
				S.insert(b[i]);
			}
			else
				v.push_back(b[i]);
		}
		else{
			S.erase(b[i]);
			if(S.empty()){
				o=1;
				x=a[i]+c[i],y=b[i];
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 8080kb

input:

3
1 0 3
10 10 6
0 5 1

output:

YES
-1 0 -1 5
4 0 4 10

result:

wrong answer Integer element x_1,y_1,x_2,y_2[1] equals to -1, violates the range [0, 10^9]