QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#615918 | #7800. Every Queen | lot | WA | 1ms | 3888kb | C++14 | 1.6kb | 2024-10-05 20:57:01 | 2024-10-05 20:57:02 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int T, n;
int a[100010], b[100010];
vector<pair<int, int> >v;
signed main() {
scanf("%lld", &T);
while (T--) {
scanf("%lld", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld%lld", &a[i], &b[i]);
}
int x = a[1], y = b[1];
int pos = 0;
for (int i = 2; i <= n; i++) {
if (x == a[i] || y == b[i])
continue;
int l1 = abs(x - a[i]), l2 = abs(y - b[i]);
if (l1 == l2)
continue;
pos = i;
break;
}
if (pos == 0) {
printf("YES\n");
printf("%lld %lld\n", x, y);
continue;
}
// cout << pos << endl;
v.clear();
v.push_back({x, b[pos]});
v.push_back({a[pos], y});
v.push_back({a[pos] + y - b[pos], y});
v.push_back({a[pos] + b[pos] - y, y});
v.push_back({x + y - b[pos], b[pos]});
v.push_back({x + b[pos] - y, b[pos]});
v.push_back({x, b[pos] + x - a[pos]});
v.push_back({x, b[pos] + a[pos] - x});
v.push_back({a[pos], y + a[pos] - x});
v.push_back({a[pos], y + x - a[pos]});
bool flag = 0;
for (int i = 0; i < v.size(); i++) {
int xx = v[i].first;
int yy = v[i].second;
//cout << xx << " " << yy << endl;
bool fl = 1;
for (int j = 2; j <= n; j++) {
if (j == pos)
continue;
int xj = a[j], yj = b[j];
if (xj == xx || yj == yy)
continue;
int x1 = abs(xx - xj), y1 = abs(yy - yj);
if (x1 == y1)
continue;
fl = 0;
break;
}
if (fl == 1) {
flag = 1;
printf("YES\n");
printf("%lld %lld\n", xx, yy);
break;
}
}
if (flag == 0) {
printf("NO\n");
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
input:
3 2 1 1 2 2 4 0 1 1 0 3 1 4 0 5 0 1 1 0 1 2 2 2 4 2
output:
YES 1 1 NO YES -1 2
result:
ok OK (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1 4 -100000000 -100000000 100000000 -100000000 -100000000 100000000 100000000 100000000
output:
YES -100000000 -100000000
result:
ok OK (1 test case)
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3812kb
input:
330 3 5 1 -3 -5 -2 2 2 1 4 4 0 4 2 -5 3 -3 -5 4 2 -2 2 -4 1 2 4 1 1 5 4 3 5 -2 3 5 2 -3 -3 5 -3 -4 2 -1 -2 -2 1 0 -1 -5 5 4 -3 -2 -4 2 2 0 -5 -4 -3 4 0 0 -3 -5 0 5 5 0 1 1 -1 5 0 2 3 4 1 4 4 5 5 0 3 -4 -5 -5 -3 5 -5 3 -1 2 -4 -4 -1 5 4 1 1 4 5 -1 0 5 2 1 -3 2 5 5 0 4 1 -3 -5 3 -3 0 0 5 0 1 -5 4 -5 5...
output:
YES 5 -5 YES 1 0 YES 2 -3 YES -4 4 YES 1 5 NO NO NO YES 0 -5 YES 1 -1 NO YES -5 -5 YES -1 -4 YES 1 2 YES -3 2 NO YES -5 -4 YES -3 2 YES -5 -3 YES -2 0 NO YES 2 0 YES 0 -1 YES 5 1 YES 0 -1 YES 1 5 YES -5 -2 YES 4 6 NO YES 5 -4 NO YES 4 3 YES 3 5 YES -1 3 YES -5 1 NO NO YES 3 -2 YES 2 4 YES 1 -4 YES -...
result:
wrong answer Jury found solution, but participant did not (test case 92)