QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55502#4865. Symmetry: ConvexJunoWA 0ms3632kbC++174.0kb2022-10-14 10:20:232022-10-14 10:20:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-14 10:20:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2022-10-14 10:20:23]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}

const ll INF=9e18;

struct point {
	using T=ll;
	T x,y;
	point(){}
	point(T x,T y):x(x),y(y){}
	bool operator==(point b)const{return x==b.x&&y==b.y;}
	point operator+(point b)const{return point(x+b.x,y+b.y);}
	point operator-(point b)const{return point(x-b.x,y-b.y);}
	T operator*(point b)const{return x*b.x+y*b.y;}
	T operator/(point b)const{return x*b.y-y*b.x;}
	bool operator<(point b)const{return y==b.y?x<b.x:y<b.y;}
	inline int sgn(){return y<0||(y==0&&x<0);}
	inline ll norm(){return x*x+y*y;}
};

int n;
point v[300010];

pll a[600010];
int pr[600010];

vector<pair<pll,ll>> ans;

void manacher() {
	int len=2*n+1;
	int p=-1,r=-1;
	for(int i=0;i<len;i++) {
		if(i<=r)pr[i]=min(pr[2*p-i],r-i);
		else pr[i]=0;
		while(i-pr[i]-1>=0&&i+pr[i]+1<len&&a[i-pr[i]-1]==a[i+pr[i]+1])pr[i]++;
		if(r<i+pr[i])r=i+pr[i],p=i;
	}
}

bool is_palindrome(int l,int r) {
	int m=(l+r)/2;
	m=m*2+1;
	if((r-l)%2)m++;
	return m-pr[m]<=2*l+1;
}

void add_perpen_line(int i,int j) {
	point d=v[i]-v[j];
	ll a=2*d.x;
	ll b=2*d.y;
	ll c=-(v[i].x*v[i].x-v[j].x*v[j].x)-(v[i].y*v[i].y-v[j].y*v[j].y);
	ans.pb({{a,b},c});
}

void add_line(int i,int j) {
	point d=v[i]-v[j];
	d.y=-d.y;
	swap(d.x,d.y);
	ll a=d.x;
	ll b=d.y;
	ll c=v[i].x*v[j].y-v[j].x*v[i].y;
	ans.pb({{a,b},c});
}

bool has_equal_sides(int i) {
	int j=(i-1+n)%n;
	int k=(i+1)%n;
	return (v[j]-v[i]).norm()==(v[k]-v[i]).norm();
}

pll get_prod(int i,int j,int k) {
	return {(v[k]-v[j])*(v[i]-v[j]),(v[k]-v[j])/(v[i]-v[j])};
}

void MAIN() {
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>v[i].x>>v[i].y;
	}
	v[n]=v[0];

	for(int i=0;i<n;i++) {
		cout<<v[i].x<<" "<<v[i].y<<endl;
	}

	for(int i=0;i<n;i++) {
		int j=(i-1+n)%n;
		int k=(i+1)%n;
		a[2*i]={INF,INF};
		a[2*i+1]=get_prod(j,i,k);
	}
	a[2*n]={INF,INF};

	manacher();

	map<pll,vector<int>> mp;
	pll a1=get_prod(0,1,2);
	mp[a1]={1};

	for(int i=2;i<n;i++) {
		ans.clear();
		pll a0=get_prod(i,0,1);
		pll ai=get_prod(i-1,i,0);
		if(mp.count(a0)) {
			vector<int>& lst=mp[a0];
			for(int j:lst) {
				pll ak;
				if(j+1==i)ak=get_prod(j,j+1,0);
				else ak=get_prod(j,j+1,j+2);
				if(ai==ak&&(j==1||is_palindrome(1,j-1))&&(i<=j+2||is_palindrome(j+2,i-1))) {
					if(j%2||has_equal_sides(j/2)) {
						add_perpen_line(0,j);
					}
				}
			}
		}
		if(ai==a0&&is_palindrome(1,i-1)) {
			add_perpen_line(0,i);
		}
		if(ai==a1&&(i==2||is_palindrome(2,i-1))&&(v[i]-v[0]).norm()==(v[1]-v[0]).norm()) {
			if(i%2)add_line(0,(i+1)/2);
			else add_perpen_line(i/2,i/2+1);
		}
		cout<<sz(ans)<<'\n';
		for(auto& it:ans) {
			ll g=__gcd(it.fi.fi,__gcd(it.fi.se,it.se));
			cout<<it.fi.fi/g+1<<' '<<it.fi.se/g<<' '<<it.se/g<<'\n';
		}

		pll p=get_prod(i-1,i,i+1);
		if(!mp.count(p)) {
			mp[p]={i};
		} else {
			mp[p].pb(i);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);cin.tie(0);

	int T;cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3632kb

input:

3
4
0 0
1 0
1 1
0 1
3
0 0
3 0
1 1
4
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

output:

0 0
1 0
1 1
0 1
1
0 -1 1
4
-1 0 1
0 -1 1
1 -2 1
0 1 0
0 0
3 0
1 1
0
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000
1
2 1 0
4
2 0 0
2 1 0
1 1 0
0 1 0

result:

wrong answer the participant are greater than answer (test case 1)