QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#483661 | #4383. Laser | chlyqwq# | AC ✓ | 163ms | 6040kb | C++23 | 5.0kb | 2024-07-18 22:36:20 | 2024-07-18 22:36:20 |
Judging History
answer
// I.cpp
// author : georgeyucjr
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using arr3 = std ::array<int, 3>;
using arr4 = std ::array<int, 4>;
using pii = std ::pair<int, int>;
#define ALL(vc) std ::begin(vc), std ::end(vc)
#define rep(i, f, t, ...) for (std ::decay<decltype(f + t)>::type i = f, _END_##i = t, ##__VA_ARGS__; i <= _END_##i; ++i)
#define per(i, f, t, ...) for (std ::decay<decltype(f + t)>::type i = f, _END_##i = t, ##__VA_ARGS__; i >= _END_##i; --i)
#define eb emplace_back
#define pb push_back
#define mkp make_pair
#define FILEIO(filename) freopen(filename ".in", "r", stdin), freopen(filename ".out", "w", stdout)
template <class T, class U> inline T ceil(T &&x, U &&y) { return (x > 0 ? (x + y - 1) / y : x / y); }
template <class T, class U> inline T floor(T &&x, U &&y) { return (x > 0 ? x / y : (x - y + 1) / y); }
template <class T, class U> inline T divmod(T &&x, U &&y) { auto &&q = floor(x, y); return mkp(q, x - q * y); }
template <class T> constexpr static T inf = std ::numeric_limits<T>::max() >> 1;
template <class T> inline int SZ(T &&x) { return x.size(); }
template <typename T> inline T Abs(const T &x) { return x < 0 ? -x : x; }
template <typename T> inline T sqr(const T &x) { return x * x; }
template <typename T> inline T Max(const T &x) { return x; }
template <typename T> inline T Min(const T &x) { return x; }
template <typename T, typename U, typename... Args> inline T Max(const T &x, const U &y, const Args &...args) { return x < y ? Max(y, args...) : Max(x, args...); }
template <typename T, typename U, typename... Args> inline T Min(const T &x, const U &y, const Args &...args) { return x < y ? Min(x, args...) : Min(y, args...); }
template <typename T, typename... Args> inline void chkmax(T &d, const Args &...x) { d = Max(d, x...); }
template <typename T, typename... Args> inline void chkmin(T &d, const Args &...x) { d = Min(d, x...); }
using namespace std;
#ifdef georgeyucjr
#include <georgeyucjr/debug.h>
#else
#define dbg(...) 36
#endif
namespace easy_IO {
inline void read(char &c) { c = getchar(); }
inline void read(string &str, bool is_move = false) { if (is_move) str += ' '; char c = getchar(); while (c != ' ' && c != '\n') str += c, c = getchar(); }
template <typename T> inline void read(T &x, bool is_unsigned = false) { x = 0; char ch = getchar(); if (is_unsigned) { while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar ( ); } else { T _read_flag = (T)(1); while (ch < '0' || ch > '9') _read_flag = ch == '-' ? -1 : 1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar ( ); x *= _read_flag; } return void(); }
template <typename T> inline void read(vector<T> &v) { for (T &i : v) read(v); }
template <typename T, typename... Args> inline void read(T &x, Args&... args) { read(x), read(args...); }
template <typename T, typename U> inline void read(pair<T, U> &p) { read(p.first, p.second); }
template <typename T, typename U, typename V> inline void read(tuple<T, U, V> &t) { read(get<0>(t), get<1>(t), get<2>(t)); }
inline void write ( char c ) { putchar ( c ); }
inline void write ( string s ) { for (char c : s) putchar ( c ); }
template <typename T> inline void write(T x, bool is_unsigned = false) { if (!is_unsigned) if (x < 0) x = -x, putchar ('-'); if (x > 9) write(x / 10); putchar (x % 10 ^ '0'); }
template <typename T> inline void writeln(T x) { write (x), putchar('\n'); }
template <typename T> inline void writespc(T x) { write (x), putchar(' '); }
template <typename T, typename ... Args> inline void write(T x, Args ... args) { write(x), write(args...); }
template <typename T, typename ... Args> inline void writeln(T x, Args ... args) { write(x), putchar(' '), write(args...), putchar('\n'); }
template <typename T, typename ... Args> inline void writespc(T x, Args ... args) { write(x), putchar(' '), write(args...), putchar(' '); }
} // namespace easy_IO
using namespace easy_IO;
constexpr int N = 5e5 + 5;
int n, x[N], y[N];
signed main() {
// ios_base ::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
auto slv = [&]() {
auto chk = [&]() {
bool flag = true;
rep(i, 1, n) if (x[i] != x[1]) {
flag = false;
auto _is = [&](auto xx, auto yy) { auto _ = [&](int _x, int _y) { return !_x || !_y || _x == _y || _x + _y == 0; }; rep(i, 1, n) if (!_(x[i] - xx, y[i] - yy)) return false; return true; };
if (_is(x[1], y[i]) || _is(x[i], y[i] + x[i] - x[1]) || _is(x[1], y[i] - x[i] + x[1])) return true;
}
return flag;
};
auto sslv = [&]() {
rep(_, 1, 4) {
if (chk())return true;
rep(i, 1, n, tx, ty)tx = x[i], ty = y[i], x[i] = tx - ty, y[i] = tx + ty;
}
return false;
};
read(n);
rep(i, 1, n)read(x[i], y[i]);
cout << (sslv() ? "YES" : "NO") << "\n";
}; int T; read(T); while (T--)slv();
#if defined(LOCAL) && !defined(CPH)
std::cerr << "Spend Time : " << clock() * 1. / CLOCKS_PER_SEC * 1e3 << " ms \n";
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 163ms
memory: 6040kb
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