QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#635651 | #4383. Laser | sslove | AC ✓ | 1200ms | 21164kb | C++20 | 6.2kb | 2024-10-12 20:29:53 | 2024-10-12 20:29:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 1e5 + 10;
int n, x, y, e;
int cnt = 0;
//int read()
//{
//// getchar();
// char c = getchar();
// int ans = 0;
// while (c <= '9' && c >= '0')
// {
// ans *= 10;
// ans += c - '0';
// c = getchar();
// }
// return ans;
//}
void solve()
{
// cout<<"Case #"<<++cnt<<": ";
unordered_map<int, int> mp1, mp2, mp3, mp4;
map<pair<int, int>, int> mp;
cin >> n;
// map<pair<int, int>, bool> mpp;
// n = read();
// cin >> n;
for (int i = 1; i <= n; i ++)
{
cin >>x >>y;
// x = read(), y = read();
mp[{x, y}] ++;
mp1[y] ++;
mp2[x] ++;
mp3[y - x] ++;
mp4[x + y] ++;
}
for (auto i : mp2)//如果x,y在横线上
{
int yy = y, xx = i.first;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp3)//如果x,y在横线上
{
int yy = y, xx = yy - i.first;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp4)//如果x,y在横线上
{
int yy = y, xx = i.first - yy;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
// mpp.clear();
for (auto i : mp1)//如果x,y在横线上
{
int yy = i.first, xx = x;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp3)//如果x,y在横线上
{
int yy = i.first + x, xx = x;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp4)//如果x,y在横线上
{
int yy = -x - i.first, xx = x ;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
// mpp.clear();
for (auto i : mp1)
{
int yy = i.first, xx = yy - (y - x);
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp2)//如果x,y在横线上
{
int yy = y - x + i.first, xx = i.first ;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp4)//如果x,y在横线上
{
int yy = (y - x + i.first);
if (yy&1)continue;
yy /= 2;
int xx = -(yy - i.first);
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
// mpp.clear();
for (auto i : mp1)//如果x,y在横线上
{
int yy = i.first, xx = -(yy - (x + y));
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp2)//如果x,y在横线上
{
int yy = y - (i.first - x), xx = i.first;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
for (auto i : mp3)//如果x,y在横线上
{
int yy = (y + x + i.first);
if (yy&1)continue;
yy /= 2;
int xx = yy - i.first;
// if (mpp.count({xx, yy}))continue;
int a = mp1.count(yy)?mp1[yy]:0;
int b = mp2.count(xx)?mp2[xx]:0;
int c = mp3.count(yy - xx)?mp3[yy - xx]:0;
int d = mp4.count(yy + xx)?mp4[yy + xx]:0;
int e = mp.count({xx, yy})?mp[{xx, yy}]:0;
if (a + b + c + d - 3 * e == n)
{
puts("YES") ;
return ;
}
// mpp[{xx, yy}] = 1;
}
// cout << "NO\n";
puts( "NO");
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// T = read();
cin >> T;
while (T --)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1200ms
memory: 21164kb
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