QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#91271 | #4383. Laser | Tobo | AC ✓ | 103ms | 5968kb | C++20 | 2.5kb | 2023-03-28 09:21:15 | 2023-03-28 09:21:19 |
Judging History
answer
#include <bits/stdc++.h>
#define N 500005
using i64 = long long;
using namespace std;
int n, x[N], y[N];
bool check(int a, int b, int c, int d)
{
if (a == c || b == d)
return true;
if (a + b == c + d)
return true;
if (a - b == c - d)
return true;
return false;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> x[i] >> y[i], x[i] *= 2, y[i] *= 2;
int p = 0;
for (int i = 1; i <= n; i++)
{
if (check(x[1], y[1], x[i], y[i]))
continue;
p = i;
break;
}
if (!p)
{
cout << "YES\n";
return;
}
int ax1 = x[1], ax2 = x[p], ay1 = y[p], ay2 = y[1];
int ax3 = (x[1] + x[p] - y[1] + y[p]) / 2, ay3 = y[p] + x[p] - ax3;
int ax4 = (x[1] + x[p] + y[1] - y[p]) / 2, ay4 = y[1] + x[1] - ax4;
int is1 = 1, is2 = 1, is3 = 1, is4 = 1;
int ax5 = x[1], ay5 = x[1] + y[p] - x[p];
int ax6 = x[1], ay6 = y[p] + y[p] - ay5;
int ay7 = y[1], ax7 = ay7 - y[p] + x[p];
int ay8 = y[1], ax8 = x[p] + y[p] - ay8;
int is5 = 1, is6 = 1, is7 = 1, is8 = 1;
int ax9 = x[p], ay9 = x[p] + y[1] - x[1];
int ax10 = x[p], ay10 = x[1] + y[1] - x[p];
int ay11 = y[p], ax11 = y[p] - y[1] + x[1];
int ay12 = y[p], ax12 = x[1] + y[1] - y[p];
int is9 = 1, is10 = 1, is11 = 1, is12 = 1;
for (int i = 1; i <= n; i++)
{
if (!check(ax1, ay1, x[i], y[i]))
is1 = 0;
if (!check(ax2, ay2, x[i], y[i]))
is2 = 0;
if (!check(ax3, ay3, x[i], y[i]))
is3 = 0;
if (!check(ax4, ay4, x[i], y[i]))
is4 = 0;
if (!check(ax5, ay5, x[i], y[i]))
is5 = 0;
if (!check(ax6, ay6, x[i], y[i]))
is6 = 0;
if (!check(ax7, ay7, x[i], y[i]))
is7 = 0;
if (!check(ax8, ay8, x[i], y[i]))
is8 = 0;
if (!check(ax9, ay9, x[i], y[i]))
is9 = 0;
if (!check(ax10, ay10, x[i], y[i]))
is10 = 0;
if (!check(ax11, ay11, x[i], y[i]))
is11 = 0;
if (!check(ax12, ay12, x[i], y[i]))
is12 = 0;
}
if (is1 || is2 || is3 || is4 || is5 || is6 || is7 || is8 || is9 || is10 || is11 || is12)
cout << "YES\n";
else
cout << "NO\n";
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 103ms
memory: 5968kb
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