QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#474685#22. Power plantsMathias0 0ms0kbC++232.1kb2024-07-12 22:04:152024-07-12 22:04:16

Judging History

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

  • [2024-07-12 22:04:16]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-07-12 22:04:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define sc second
#define vi vector<int>
#define pii pair<int,int>
const ll INF = 1e18+7;
const int MAXN = 1e5+7;
pii t[MAXN]; bool vis[MAXN],k[MAXN],xd; pii p; int depth[MAXN],v1[MAXN],v2[MAXN];
vi g[MAXN]; int tmp,usu,n,rv1,rv2,rp;
struct str{int fi,sc,th;};
str pkt[MAXN];
bool comp(str a,str b){
	if(a.fi==b.fi) return a.sc<b.sc;
	else return a.fi<b.fi;
}
set<pii>s;
ll d(int x,int y){ 
	ll w1=t[x].fi, w2=t[x].sc, w3=t[y].fi, w4=t[y].sc;
	return (w1-w3)*(w1-w3)+(w2-w4)*(w2-w4); 
}
void DFS(int x,int f){
	if(xd==0) return;
	k[x]=1-k[f], vis[x]=1, depth[x]=depth[f]+1;
	for(auto s1:g[x]) 
		if(vis[s1]==1 and s1!=f and (depth[x]-depth[s1])%2==0 and k[x]==k[s1]){ xd=0; return; } 
		else if(vis[s1]==0) DFS(s1,x);
}
bool f(ll mid){
	xd=1; usu=0; int l=0,x,y;
	s.clear(); for(int i=0;i<rp;i++) g[pkt[i].th].clear(), vis[pkt[i].th]=0;
	ll prw=sqrt(mid);
	for(int i=0;i<rp;i++){
		//cout<<i<<'\n';
		l=0;
		x=pkt[i].fi, y=pkt[i].sc;
		while(pkt[usu].fi-x<prw) s.erase({pkt[usu].sc,pkt[usu].th}), usu++; 
		p={max((ll)0,y-prw),0};
		auto it=s.lower_bound(p);
		for(auto curr=it;curr!=s.end();curr++){
			l++;
			p=*curr;
			if(l>17) return 0;
			if(p.fi>y+prw) break;
			if(d(p.sc,pkt[i].th)<mid) g[pkt[i].th].pb(p.sc), g[p.sc].pb(pkt[i].th);
		}	
		s.insert({y,pkt[i].th});
	}
	for(int i=1;i<=n;i++){
		if(vis[i]==0) DFS(i,0);
		if(xd==0) break;
	}
	if(xd==1){
		rv1=rv2=0;
		for(int i=1;i<=n;i++) if(k[i]) v1[++rv1]=i; else v2[++rv2]=i;
	} 
	return xd;
}
void solve(){
	ll b=0,e=INF,mid,r=0;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>t[i].fi>>t[i].sc, pkt[rp++]={t[i].fi,t[i].sc,i};
	sort(pkt,pkt+rp,comp);
	while(b<=e){
		mid=(b+e)/2;
		if(f(mid)) r=mid, b=mid+1; else e=mid-1;
	}
	cout<<r<<'\n'<<rv1<<'\n';
	for(int i=1;i<=rv1;i++) cout<<v1[i]<<' '; cout<<'\n'<<rv2<<'\n';
	for(int i=1;i<=rv2;i++) cout<<v2[i]<<' '; cout<<'\n';
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tt=1;
	while(tt--) solve();	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

100
387 501
90 108
273 76
754 365
121 556
102 401
831 215
841 829
424 690
17 35
10 980
34 917
948 478
766 818
55 588
510 772
16 511
499 323
632 554
461 454
281 247
720 575
994 720
739 30
989 992
507 557
665 621
356 398
161 822
906 556
189 835
208 500
628 829
402 969
804 155
697 581
107 630
102 568
3...

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%