QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#135730#6639. Disk TreePhantomThresholdWA 1ms3548kbC++202.4kb2023-08-05 23:22:552023-08-05 23:22:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-05 23:22:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3548kb
  • [2023-08-05 23:22:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct circ
{
	int x,y,r,id;
	bool operator<(const circ &c)const{return y<c.y;}
};
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<circ> c(n+5);
	vector<pair<int,int>> events;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i].x>>c[i].y>>c[i].r;
		c[i].id=i;
		events.emplace_back(max(c[i].x-c[i].r,0),-i);
		events.emplace_back(c[i].x+c[i].r,i);
	}
	sort(events.begin(),events.end());
	vector<int> pa(n+5);
	function<int(int)> find=[&](int x){return pa[x]?pa[x]=find(pa[x]):x;};
	set<circ> s;
	vector<tuple<int,int,int,int>> ans;
	int prepos=-1;
	vector<int> mark;
	for(auto [pos,t]:events)
	{
		if(pos>prepos or t>0)
		{
			for(auto u:mark)
			{
				auto it=s.lower_bound(c[u]);
				if(it!=s.end())
				{
					int pu=find(it->id),pv=find(u);
					if(pu!=pv)
					{
						ans.emplace_back(prepos,c[u].y,prepos,it->y);
						pa[pv]=pu;
					}
				}
				if(it!=s.begin())
				{
					--it;
					int pu=find(it->id),pv=find(u);
					if(pu!=pv)
					{
						ans.emplace_back(prepos,c[u].y,prepos,it->y);
						pa[pv]=pu;
					}
				}
			}
			mark.clear();
		}
		if(t<0)
		{
			t=-t;
			mark.push_back(t);
			s.insert(c[t]);
		}
		else
		{
			s.erase(c[t]);
		}
		prepos=pos;
	}
	for(auto u:mark)
	{
		auto it=s.lower_bound(c[u]);
		if(it!=s.end())
		{
			int pu=find(it->id),pv=find(u);
			if(pu!=pv)
			{
				ans.emplace_back(prepos,c[u].y,prepos,it->y);
				pa[pv]=pu;
			}
		}
		if(it!=s.begin())
		{
			--it;
			int pu=find(it->id),pv=find(u);
			if(pu!=pv)
			{
				ans.emplace_back(prepos,c[u].y,prepos,it->y);
				pa[pv]=pu;
			}
		}
	}
	mark.clear();
	vector<int> minx(n+5,1e9),maxx(n+5,-1e9);
	vector<int> miny(n+5),maxy(n+5);
	for(int i=1;i<=n;i++)
	{
		if(minx[find(i)]>max(c[i].x-c[i].r,0))
			minx[find(i)]=max(c[i].x-c[i].r,0),miny[find(i)]=c[i].y;
		if(maxx[find(i)]<c[i].x+c[i].r)
			maxx[find(i)]=c[i].x+c[i].r,maxy[find(i)]=c[i].y;
	}
	vector<pair<int,int>> srt;
	for(int i=1;i<=n;i++)
	{
		if(find(i)==i)
		{
			srt.emplace_back(minx[i],miny[i]);
			srt.emplace_back(maxx[i],maxy[i]);
		}
	}
	sort(srt.begin(),srt.end());
	for(int i=1;i+1<(int)srt.size();i+=2)
	{
//		cerr<<"fuck "<<endl;
		ans.emplace_back(srt[i].first,srt[i].second,srt[i+1].first,srt[i+1].second);
	}
	cout<<"YES"<<endl;
	for(auto [a,b,c,d]:ans)
		cout<<a<<' '<<b<<' '<<c<<' '<<d<<"\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3532kb

input:

3
1 0 3
10 10 6
0 5 1

output:

YES
0 5 0 0
4 10 4 0

result:

ok answer = 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3464kb

input:

2
1 1 1
3 3 1

output:

YES
2 3 2 1

result:

ok answer = 1

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3548kb

input:

5
10 10 10
2 0 1
20 20 1
3 20 1
20 0 1

output:

YES
2 20 2 10
19 20 19 10
1 0 3 0
19 0 21 0

result:

wrong answer Two disks cannot reach eachother