QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#260337 | #7800. Every Queen | DoorKickers# | WA | 1ms | 3428kb | C++20 | 4.1kb | 2023-11-22 02:08:58 | 2023-11-22 02:08:59 |
Judging History
answer
#include <bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <climits>
#include <functional>
#include <iomanip>
#include <queue>
#include <set>
#include <valarray>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define rep(a, b, c) for (int a = b; a <= c; a++)
#define per(a, b, c) for (int a = c; a >= b; a--)
#define all(a) a.begin() + 1, a.end()
#define all_(a) a.begin(), a.end()
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
int mod = 998244353;
ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fp_m (ll a, ll n) {
a %= mod;
ll res = 1; while (n) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res;
}
ll fp (ll a, ll n) {
ll res = 1; while (n) { if (n & 1) res *= a; a *= a; n >>= 1; } return res;
}
ll inv(ll x) {return fp_m(x, mod - 2);}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i];
if (i < vec.size() - 1)
os << ", ";
}
os << "]";
return os;
}
template<typename T, typename... Args>
void debug(std::string name, T value, Args &&...arg) {
std::cout << name;
(..., (std::cout << '[' << arg << ']'));
std::cout << " = " << value << '\n';
}
//中文测试 中文测试
signed main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0); std::cout.tie(0);
int tt; std::cin >> tt;
while (tt--) {
int n; std::cin >> n;
int X, Y, XY, YX;
std::vector<long long> x(n + 1), y(n + 1);
for (int i = 1; i <= n; i++) {
std::cin >> x[i] >> y[i];
}
if (n == 1) {
std::cout << "YES" << '\n';
std::cout << x[1] << ' ' << y[1] << '\n';
continue;
}
bool flag = 1;
for (int i = 2; i <= n; i++) {
if (x[i] == X || y[i] == Y || x[i] - y[i] == XY || YX == x[i] + y[i]) {
continue;
} else {
flag = 0;
// four edges :
// 1.
// 2.
// Y = X + (y - x)
// Y = -X + (x + y)
// Y = X + (y - x)
// Y = X + (y - x)
// Y = -X + (x + y)
// X + (y - x) = -X + (x2 + y2)
// X = (x2 + x + y2 - y) / 2;
// Y = X + (y - x)
std::vector<std::pair<int, int>> points = {{x[i], y[1]}, {x[1], y[i]}, {x[i], x[i] + (y[1] - x[1])}, {y[i] - y[1] + x[1], y[i]},
{x[i], -x[i] + (x[1] + y[1])}, {-y[i] + (x[1] + y[1]), y[i]}, {x[1], x[1] + (y[i] - x[i])}, {y[1] - y[i] + x[i], y[1]},
{x[1], -x[1] + (x[i] + y[i])}, {-y[1] + (x[i] + y[i]), y[1]}, {(x[i] - y[i] + x[1] + y[1]) / 2, (x[i] - y[i] + x[1] + y[1]) / 2 + (y[i] - x[i])}, {(x[1] - y[1] + x[i] + y[i]) / 2, (x[1] - y[1] + x[i] + y[i]) / 2}};
for (auto [xx, yy] : points) {
bool fl = 1;
for (int j = 1; j <= n; j++) {
if (xx != x[j] && yy != y[j] && abs(xx - x[j]) != abs(yy - y[j])) {
fl = 0;
break;
}
}
if (fl == 1) {
std::cout << "YES" << '\n';
std::cout << xx << ' ' << yy << '\n';
goto ed;
}
}
break;
}
}
if (flag == 0)
std::cout << "NO" << '\n';
else {
std::cout << "YES" << '\n';
std::cout << x[1] << ' ' << y[1] << '\n';
}
ed:;
}
return 0;
}
/*
1 2 3 4 5 6
[1, 1]
[2, 2]
[3, 3]
[4, 2]
[5, 1]
[6, 1]
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3376kb
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: 1ms
memory: 3380kb
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: 3428kb
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 -3 1 YES 1 4 YES 2 -3 YES 2 1 YES 1 5 NO NO NO YES 0 -5 YES 1 -1 NO YES -5 -5 YES -4 5 YES 1 2 YES -3 2 NO YES -5 -4 YES -3 0 YES -5 -3 YES -2 0 NO YES 2 0 NO YES 5 1 YES 0 -1 YES 1 5 YES -5 -2 YES 4 6 NO YES 5 -4 NO YES 1 -4 YES 3 5 NO YES -5 1 NO NO YES 3 5 YES 2 4 YES 1 -4 YES -2 -5 NO YES -1...
result:
wrong answer Queen (4, 0) does not attack square (1, 4) (test case 2)