QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#47700 | #4383. Laser | ckiseki# | AC ✓ | 93ms | 4716kb | C++ | 2.1kb | 2022-09-10 16:10:00 | 2022-09-10 16:10:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int cx[4] = {1, 0, 1, 1};
const int cy[4] = {0, 1, 1, -1};
int calc(pair<int,int> p, int j) {
return cx[j]*p.first + cy[j]*p.second;
}
pair<int,int> jiao(pair<int,int> p, int i, pair<int,int> q, int j) {
int v1 = calc(p, i);
int v2 = calc(q, j);
int x = 0, y = 0;
if (cy[j]*cx[i] - cy[i]*cx[j] != 0) {
x = (cy[j] * v1 - cy[i] * v2) / (cy[j] * cx[i] - cy[i] * cx[j]);
y = (cx[j] * v1 - cx[i] * v2) / (cy[i] * cx[j] - cy[j] * cx[i]);
}
return { x, y };
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<pair<int,int>> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i].first >> p[i].second;
}
bool ans = false;
for (int j = 0; j < 4; j++) {
vector<int> mark(n);
int f = -1;
for (int i = 0; i < n; i++) {
if (calc(p[i], j) == calc(p[0], j)) {
mark[i] = true;
} else {
f = i;
}
}
if (f == -1) {
ans = true;
break;
} else {
for (int k = 0; k < 4; k++) {
auto m = jiao(p[0], j, p[f], k);
bool ok = true;
for (int i = 0; i < n; i++) {
bool fnd = false;
for (int l = 0; l < 4; l++) {
if (calc(m, l) == calc(p[i], l))
fnd = true;
}
if (!fnd)
ok = false;
}
if (ok) {
// cerr << "m = " << m.first << ' ' << m.second << endl;
ans = true;
break;
}
}
}
}
if (ans) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 93ms
memory: 4716kb
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