QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#141541#5251. ConstellationsPhantomThreshold#WA 452ms128624kbC++202.5kb2023-08-17 16:11:562023-08-17 16:11:57

Judging History

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

  • [2023-08-17 16:11:57]
  • 评测
  • 测评结果:WA
  • 用时:452ms
  • 内存:128624kb
  • [2023-08-17 16:11:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
struct frac{
	ll p,q;
	inline frac(){p=0;q=1;}
	inline frac(ll x){p=x;q=1;}
	inline frac(ll x,ll y){ll d=__gcd(x,y);p=x/d;q=y/d;if (q<0) p=-p,q=-q;}
	frac operator + (const frac &x){return frac(p*x.q+q*x.p,q*x.q);}
	frac operator - (const frac &x){return frac(p*x.q-q*x.p,q*x.q);}
	frac operator * (const frac &x){return frac(p*x.p,q*x.q);}
	frac operator / (const frac &x){return frac(p*x.q,q*x.p);}
	bool operator < (const frac &x)const{return p*x.q<q*x.p;}
	bool operator == (const frac &x)const{return p*x.q==q*x.p;}
	bool operator > (const frac &x)const{return p*x.q>q*x.p;}
	void print(){
		cout << p << "/" << q;	
	}
};
struct point{
	frac x,y;
	point operator + (const point &k){return (point){x+k.x,y+k.y};}
	point operator - (const point &k){return (point){x-k.x,y-k.y};}
	point operator * (frac k){return (point){x*k,y*k};}
	point operator / (frac k){return (point){x/k,y/k};}
	frac abs2(){return x*x+y*y;}
	frac dis2(point k){return ((*this)-k).abs2();}
	void print(){
		cout << "(";
		x.print();
		cout << ",";
		y.print();
		cout << ") ";
	}
};

const int maxn=6000;

int n;
point a[maxn+50];
int sz[maxn+50];

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i=1;i<=n;i++){
		int x,y;
		cin >> x >> y;
		a[i]=(point){frac(x),frac(y)};	
	}
	set<tuple<frac,int,int>> s;
	for (int i=1;i<=n;i++) sz[i]=1;
	int id=n;
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			s.emplace(a[i].dis2(a[j]),i,j);	
		}
	}
	for (int cnt=1;cnt<=10;cnt++){
		if (s.empty()) break;
		
		auto tmp=*(s.begin());
		int x=get<1>(tmp);
		int y=get<2>(tmp);
		sz[++id]=sz[x]+sz[y];
		a[id]=(a[x]*sz[x]+a[y]*sz[y])/(sz[x]+sz[y]);
		
		for (int i=1;i<id;i++) if (sz[i]!=0){
			int l=i,r=x;
			if (l>r) swap(l,r);
			auto it=s.find(make_tuple(a[l].dis2(a[r]),l,r));
			if (it!=s.end()) s.erase(it);
		}
		sz[x]=0;
		for (int i=1;i<id;i++) if (sz[i]!=0){
			int l=i,r=y;
			if (l>r) swap(l,r);
			auto it=s.find(make_tuple(a[l].dis2(a[r]),l,r));
			if (it!=s.end()) s.erase(it);
		}
		sz[y]=0;
		
		for (int i=1;i<id;i++) if (sz[i]!=0){
			s.emplace(a[i].dis2(a[id]),i,id);
		}
	//	cout << "sz[id] : ";
		cout << sz[id] << "\n";
		/*
		cout << "id : " << id << endl;
		for (int i=1;i<=id;i++) a[i].print();
		cout << endl;
		for (int i=1;i<=id;i++) cout << sz[i] << " ";
		cout << endl;
		for (auto [x,i,j]:s){
			cout << "dis2,i,j : ";
			x.print();
			cout << " " << i << " " << j << endl;	
		}
		*/
	}
	return 0;
}

詳細信息

Test #1:

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

input:

2
0 0
1 0

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 452ms
memory: 128624kb

input:

2000
1000 -1000
1000 -999
1000 -998
1000 -997
1000 -996
1000 -995
1000 -994
1000 -993
1000 -992
1000 -991
1000 -990
1000 -989
1000 -988
1000 -987
1000 -986
1000 -985
1000 -984
1000 -983
1000 -982
1000 -981
1000 -980
1000 -979
1000 -978
1000 -977
1000 -976
1000 -975
1000 -974
1000 -973
1000 -972
1000...

output:

2
2
2
2
2
2
2
2
2
2

result:

wrong answer 11th lines differ - expected: '2', found: ''