QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97488#4383. Laser3360550356AC ✓263ms13996kbC++142.9kb2023-04-16 22:00:492023-04-16 22:00:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-16 22:00:51]
  • 评测
  • 测评结果:AC
  • 用时:263ms
  • 内存:13996kb
  • [2023-04-16 22:00:49]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const int N = 5e5+10;
const int M = 1e3 + 100;
const int mod = 1e9+7;
const int INF=1e9;
const double PI=acos(-1);
const double eps=1e-10;

//计算几何,旋转,相交 
int X[N],Y[N];
int x[N],y[N];
int n;

int check3(int xx, int yy){ return xx==0||yy==0||xx==yy||xx+yy==0; }

//即把n个点与目标点确认 
bool check2(int sx,int sy){
	for(int i=1;i<=n;i++){
		if(!check3(sx-x[i],sy-y[i]))return 0;
	}
	return 1;
	
} 

bool check(){
	
	int flag=1;
	for(int i=2;i<=n;i++){
		if(y[i]==y[1])continue;
		flag=0;			
		
		if(check2(x[i],y[1]))return 1;//以(x[1],y[i])为中心的米
        if(check2(x[i]-(y[i]-y[1]),y[1]))return 1;//两条斜线交点作为米中心
        if(check2(x[i]+(y[i]-y[1]),y[1]))return 1;
        break;
	}
	return flag; 		//全在一条线上也是可行的 
	
}

//bool check(){
//	
//	int flag=1;
//	for(int i=2;i<=n;i++){
//		if(x[i]==x[1])continue;
//		flag=0;			
//		
//		if(check2(x[1],y[i]))return 1;//以(x[1],y[i])为中心的米
//        if(check2(x[1],y[i]+(x[i]-x[1])))return 1;//两条斜线交点作为米中心
//        if(check2(x[1],y[i]-(x[i]-x[1])))return 1;
//        break;
//	}
//	return flag; 		//全在一条线上也是可行的 
//	
//}

void solve(){


//	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>X[i]>>Y[i];
	} 
	//如果可行,每个点最终只可能是横,竖,左斜,右斜四种情况
	//旋转四次
	
	for(int i=1;i<=n;i++)x[i]=X[i],y[i]=Y[i];
	if(check()){
		cout<<"YES"<<endl;
		return;
	}

	for(int i=1;i<=n;i++)x[i]=Y[i],y[i]=X[i];
	if(check()){
		cout<<"YES"<<endl;
		return;
	}
	
	for(int i=1;i<=n;i++)x[i]=X[i]+Y[i],y[i]=X[i]-Y[i];
	if(check()){
		cout<<"YES"<<endl;
		return;
	}
	
	for(int i=1;i<=n;i++)x[i]=X[i]-Y[i],y[i]=X[i]+Y[i];
	if(check()){
		cout<<"YES"<<endl;
		return;
	}
	
	cout<<"NO"<<endl;
	
	 
	
	
}
signed main() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(0);
	int T=1;
	cin>>T;
	while(T--) {
		solve();
	}
}

/**
*  ┏┓   ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃       ┃
* ┃   ━   ┃ ++ + + +
*  ████━████+
*  ◥██◤ ◥██◤ +
* ┃   ┻   ┃
* ┃       ┃ + +
* ┗━┓   ┏━┛
*   ┃   ┃ + + + +Code is far away from  
*   ┃   ┃ + bug with the animal protecting
*   ┃    ┗━━━┓ 神兽保佑,代码无bug 
*   ┃        ┣┓
*    ┃        ┏┛
*     ┗┓┓┏━┳┓┏┛ + + + +
*    ┃┫┫ ┃┫┫
*    ┗┻┛ ┗┻┛+ + + +
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 263ms
memory: 13996kb

input:

116
4
-10 0
10 0
5 5
-5 -5
4
-10 0
10 0
0 10
0 -10
4
-1 0
1 0
2 0
3 0
4
0 1
0 2
0 3
0 4
4
100 100
10000 10000
100000 100000
-100 -100
4
-100 100
-10000 10000
-100000 100000
100 -100
6
1 1
1 3
2 2
3 1
3 3
3 4
7
1 1
1 3
2 2
3 1
3 3
1 4
3 4
4
1236833 14678
1232056 9901
1237055 9790
1231834 15011
4
1236...

output:

YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
NO
YES
NO...

result:

ok 116 lines