QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#73049 | #4383. Laser | LiCooer | AC ✓ | 440ms | 11944kb | C++17 | 2.9kb | 2023-01-21 17:49:05 | 2023-01-21 17:49:08 |
Judging History
answer
//By TOP
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
#include <bits/stdc++.h>
#include <deque>
#include <vector>
#include <utility>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define OO 0x3f3f3f3f
#define rd read()
#define mem(a,b) memset(a,b,sizeof a)
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define v1 priority_queue<int,vector<int>,greater<int> > v
#define v2 priority_queue<int,vector<int>,less<int> > v
#define debug(a) cout << a << "\n"
const int N = 2000010;
int a[N];
int n;
int tr[N];
/*void build(int u , int l , int r)
{
tr[u] = {l , r};
if(l == r)
{
return ;
}
int mid = l + r >> 1;
build(u << 1 , l , mid);
build(u << 1 | 1 , mid + 1 ,r);
}*/
/*int query(int u , int l , int r)
{
if(tr[u].l >= l && tr[u].r <= r)
{
return tr[u].v;
}
int mid = tr[u].l + tr[u].r >> 1;
int v = 0;
if(l <= mid)
{
v.query(u << 1 , l , r);
}
if(r > mid)
{
v.query(u << 1 | 1 , l , r);
}
return v;
}*/
/*int lowbit(int x)
{
return x & -x;
}
void add(int x,int c)
{
for(int i = x ; i <= n ; i += lowbit(i) )
{
tr[i] += c;
}
}
int query(int x)
{
int res = 0;
for(int i = x ; i ; i -= lowbit(i))
{
res += tr[i];
}
return res;
}*/
int b[N];
int x[N];
int y[N];
bool pd(int x , int y)
{
if(!x || !y || x + y == 0 || x == y)
{
return true;
}
return false;
}
bool cheak(int x1 , int y1)
{
for(int i = 1 ; i <= n ; i ++ )
{
if(!pd(x1 - x[i] , y1 - y[i]))
{
return false;
}
}
return true ;
}
bool cheak()
{
bool flag = true;
for(int i = 1 ; i <= n ; i ++ )
{
if(x[i] == x[1])
{
continue;
}
flag = false;
if(cheak(x[1] , y[i]))
{
return true;
}
if(cheak(x[1] , y[i] + (x[i] - x[1])))
{
return true;
}
if(cheak(x[1] , y[i] - (x[i] - x[1])))
{
return true;
}
}
if(!flag)
{
return false;
}
return true;
}
bool solve()
{
cin >> n;
for(int i = 1 ; i <= n ; i ++ )
{
cin >> a[i] >> b[i];
}
for(int i = 1 ; i <= n ; i ++ )
{
x[i] = a[i];
y[i] = b[i];
}
if(cheak())
{
return 1;
}
for(int i = 1 ; i <= n ; i ++ )
{
x[i] = b[i];
y[i] = a[i];
}
if(cheak())
{
return 1;
}
for(int i = 1 ; i <= n ; i ++ )
{
x[i] = a[i] + b[i];
y[i] = a[i] - b[i];
}
if(cheak())
{
return 1;
}
for(int i = 1 ; i <= n ; i ++ )
{
x[i] = a[i] - b[i];
y[i] = a[i] + b[i];
}
if(cheak())
{
return 1;
}
return 0;
}
signed main()
{
ios;
int t = 1;
cin >> t;
while(t -- )
{
if(solve())
{
cout << "YES" << "\n";
}
else
{
cout << "NO" << "\n";
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 440ms
memory: 11944kb
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