QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#73040 | #4383. Laser | poi | AC ✓ | 90ms | 4076kb | C++ | 2.0kb | 2023-01-21 17:17:38 | 2023-01-21 17:17:41 |
Judging History
answer
#include "iostream"
#include "cstring"
#include "cstdio"
#include "algorithm"
#include "queue"
#include "vector"
#include "queue"
#include "stack"
#include "ctime"
#include "set"
#include "map"
#include "cmath"
using namespace std;
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define rep( i , a , b ) for( int i = (a) , i##end = b ; i <= i##end ; ++ i )
#define per( i , a , b ) for( int i = (a) , i##end = b ; i >= i##end ; -- i )
#define mem( a ) memset( a , 0 , sizeof (a) )
#define all( x ) x.begin() , x.end()
//#define int long long
typedef long long ll;
const int P = 998244353;
const int MAXN = 5e5 + 10;
int n;
int X[MAXN] , Y[MAXN];
bool neq( double a , double b ) {
return fabs( a - b ) > 1e-6;
}
int check( double x , double y ) {
rep( i , 1 , n ) {
if( neq( X[i] , x ) && neq( y , Y[i] ) && neq( X[i] - x , Y[i] - y ) && neq( X[i] - x , y - Y[i] ) ) {
return i;
}
}
return 0;
}
void solve() {
cin >> n;
rep( i , 1 , n ) {
scanf("%d%d",X + i,Y + i);
}
int f = check( X[1] , Y[1] );
if( !f ) {
puts("YES"); return;
}
double x1 = X[1] , y1 = Y[1] , x2 = X[f] , y2 = Y[f];
if( !check( ( x1 + x2 + y2 - y1 ) / 2 , ( y1 + y2 + x2 - x1 ) / 2 ) ||
!check( ( x1 + x2 + y1 - y2 ) / 2 , ( y1 + y2 + x1 - x2 ) / 2 ) ) {
puts("YES"); return;
}
if( !check( x1 , y2 ) || !check( x2 , y1 ) ) {
puts("YES"); return;
}
if( !check( x1 , x2 - x1 + y2 ) || !check( x1 , y2 - x2 + x1 ) || !check( x2 + y2 - y1 , y1 ) || !check( x2 - y2 + y1 , y1 ) ) {
puts("YES"); return;
}
swap( x1 , x2 ) , swap( y1 , y2 );
if( !check( x1 , x2 - x1 + y2 ) || !check( x1 , y2 - x2 + x1 ) || !check( x2 + y2 - y1 , y1 ) || !check( x2 - y2 + y1 , y1 ) ) {
puts("YES"); return;
}
puts("NO");
}
signed main() {
// freopen("in","r",stdin);
// freopen("out","w",stdout);
int T;cin >> T;while( T-- ) solve();
// solve();
}
详细
Test #1:
score: 100
Accepted
time: 90ms
memory: 4076kb
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