結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
Astral__
|
| 提出日時 | 2024-01-12 22:03:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 10,171 bytes |
| コンパイル時間 | 2,574 ms |
| コンパイル使用メモリ | 202,316 KB |
| 最終ジャッジ日時 | 2025-02-18 18:17:59 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 WA * 38 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//using uLL = unsigned __int128;
using PT = priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>>;
using PPQ = priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>;
using PQ = priority_queue<ll, vector<ll>, greater<ll>>;
using P = pair<ll, ll>;
using vvvvl = vector<vector<vector<vector<ll>>>>;
using vvvi = vector<vector<vector<int>>>;
using vvvl = vector<vector<vector<ll>>>;
using vvvc = vector<vector<vector<char>>>;
using vvvd = vector<vector<vector<double>>>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvs = vector<vector<string>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<pair<ll, ll>>>;
using vvb = vector<vector<bool>>;
using vvd = vector<vector<double>>;
using vp = vector<pair<ll, ll>>;
using vi = vector<int>;
using vl = vector<ll>;
using vu = vector<unsigned long long>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
#define vvvm vector<vector<vector<mint>>>
#define vvm vector<vector<mint>>
#define vm vector<mint>
#define umap unordered_map
#define uset unordered_set
#define rrr(l, r) mt()%(r-l+1)+l
#define rep(i, s, f) for(long long i = s; i <= f; i++)
#define rep1(i, s, f) for(long long i = s; i <= f; i++)
#define per(i, s, f) for(long long i = s; i >= f; i--)
#define per1(i, s, f) for(long long i = s; i >= f; i--)
#define all0(x) (x).begin() ,(x).end()
#define all(x) (x).begin() + 1, (x).end()
#define ENDL '\n'
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//これが本当の組み込み関数ってね(笑)
template <typename T>
T or_less(vector<T> &A, T x) { //x以下で最大要素の添字 前提: sort済み 存在しない: -1
return distance(A.begin(), upper_bound(A.begin(), A.end(), x)-1);
}
template <typename T>
T under(vector<T> &A, T x) { //x未満の最大要素の添字 前提: sort済み 存在しない: -1
return distance(A.begin(), lower_bound(A.begin(), A.end(), x)-1);
}
template <typename T>
T or_more(vector<T> &A, T x) { //x以上で最小要素の添字 前提: sort済み 存在しない: 配列のサイズ . //distanceのA.beginは添字を出すために常にA.begin() NG: A.begin() + 1
return distance(A.begin(), lower_bound(A.begin(), A.end(), x));
}
template <typename T>
T over(vector<T> &A, T x) { //xより大きい最小要素の添字前提: sort済み 存在しない: 配列のサイズ
return distance(A.begin(), upper_bound(A.begin(), A.end(), x));
}
template <typename T>
vector<T> vec_shift(vector<T> A, ll step, ll dir, ll indexed) {//dir = 1 : 右シフト dir = -1 : 左シフト
ll N = A.size() - indexed;
vector<T> res(N+1);
rep(i, indexed, N) {
ll idx = i - step * dir;
if(idx < indexed) idx += N;
if(idx > N) idx -= N;
res.at(i) = A.at(idx);
}
return res;
}
template <typename T>
void UNIQUE(vector<T> &A, int indexed) {
sort(A.begin() + indexed, A.end());
A.erase(unique(A.begin() + indexed, A.end()), A.end());
}
template <typename T>
vector<T> RLE(vector<T> &A, int indexed) {
vector<T> res(indexed, -INT_MAX);
for(int i = indexed; i < int(A.size()); i++) {
if(i == indexed) res.push_back(A[i]);
else if(A[i-1] != A[i]) res.push_back(A[i]);
}
return res;
}
template <typename T>
void rev90(vector<vector<T>> &A, int indexed) {
reverse(A.begin() + indexed, A.end());
int n = A.size();
rep(i, indexed, n-1) {
rep(j, i+1, n-1) {
swap(A.at(i).at(j), A.at(j).at(i));
}
}
}
int msb(long long a) {
if(a == 0) return -1;
return 64 - int(__builtin_clzll(a));
}
template<typename T = long long>
void chmin(T &a, T b) {
a = min(a, b);
}
template<typename T = long long>
void chmax(T &a, T b) {
a = max(a, b);
}
//////////////////////////////////////////////////////////////////////
//数学系
///////////////////////////////////////////////////////////////////////
ll round(ll x, ll i) {return ll(x + 5 * powl(10, i-1))/ll(powl(10, i)) * ll(powl(10, i));}
vp insu_bunkai(ll N) {
vp res;
for (ll i = 2; i * i <= N; i++) {
ll cnt = 0;
while(N % i == 0) {
cnt++;
N /= i;
}
if(cnt != 0) res.push_back(P(i, cnt));
}
if(N != 1) res.push_back(P(N, 1));
return res;
}
ll extgcd (ll a, ll b, ll &x, ll &y) {
if(b == 0) { x = 1;y = 0;return a;}
ll d = extgcd(b, a%b, y, x);
y -= a/b * x;
return d;
}
template <typename T>
T ceil(T a, T b) {
assert(b != 0);
if(a % b == 0) return a / b;
if((a <= 0 && b < 0) || (a >= 0 && b > 0)) return a/b + 1;
else return a / b;
}
template <typename T>
T floor(T a, T b) {
assert(b != 0);
if(a % b == 0) return a / b;
if((a <= 0 && b < 0) || (a >= 0 && b > 0)) return a/b;
else return a/b - 1;
}
long long Calnum(long long l, long long r, long long M, long long m) {//[l, r]で、modMがmである数の個数
l -= m; r -= m;//並行移
l = ceil(l, M) * M;
r = floor(r, M) * M;
if(l > r) return 0LL;
return (r - l)/M+1;
}
ll modpow(ll x, ll y, ll mod) {
if(x > mod) x %= mod;
if(y == 0) return 1;
ll res = modpow(x, y >> 1, mod);
res = res * res % mod;
if(y & 1) res *= x, res %= mod;
return res;
}
ll sqrt_(ll a) {
ll l = 0;
ll r = 3037000499LL;
while(l < r) {
ll mid = (l + r + 1) / 2;
if(mid * mid <= a) l = mid;
else r = mid - 1;
}
return l;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//グローバル変数を置くところ(情報工学意識高め)
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
const ll int_max = 1001001001;
const ll ll_max = 1001001001001001001LL;
const double pi = 3.141592653589793;
vl dx{0, 1, 0, -1, 0, 1, 1, -1, -1}; // 座標平面において、(番兵) → ↓ ← ↑ ※ 右から時計回り 注 : グリッド or 座標で上下は反転する。
vl dy{0, 0, -1, 0, 1, 1, -1, -1, 1};
//const ll mod = 1000000007;
//const ll mod = 998244353;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const double eps = 1e-5 ;
int sgn(const double a) {
return (a < -eps ? -1 : (a > eps ? 1 : 0));
//点が全て整数(制度100%) return (a < 0 ? -1 : (a > 0 ? 1 : 0));
}
void solve() {
ll Q;
cin >> Q;
vd xs(4), ys(4);
rep(i,1,3) cin >> xs[i] >> ys[i];
auto d = [](double sx, double sy, double tx, double ty) {
return sqrt((sx - tx) * (sx - tx) + (sy - ty) * (sy - ty));
};
auto dist = [&](double x) {
double ly = -10000;
double ry = 10000;
rep(t, 1, 100) {
double m1 = (2 * ly + ry)/3;
double m2 = (ly + 2 * ry)/3;
double d1 = 0, d2 = 0;
rep(i,1,3) d1 = max(d1, d(xs[i], ys[i], x, m1));
rep(i,1,3) d2 = max(d2, d(xs[i], ys[i], x, m2));
if(d1 > d2) {
ly = m1;
}
else {
ry = m2;
}
}
double res = 0;
rep(i,1,3) res = max(res, d(xs[i], ys[i], x, ly));
return make_pair(res, ly);
};
double lx = -10000;
double rx = 10000;
double cy = 0;
rep(i, 1, 100) {
double m1 = (2 * lx + rx)/3;
double m2 = (lx + 2 * rx)/3;
auto [d1, y1] = dist(m1);
auto [d2, y2] = dist(m2);
if(d1 > d2) {
lx = m1;
cy = y2;
}
else {
rx = m2;
cy = y1;
}
}
double cx = lx;
auto r = dist(cx).first;
rep(qi,1,Q) {
double x, y;
cin >> x >> y;
double dis = d(x, y, cx, cy);
if(sgn(dis - r) == 1) {
cout << "No" << ENDL;
}
else {
cout << "Yes" << ENDL;
}
}
}
//無闇にumapを使わない(特に平方分割時、必要ない事が多い(想定解が平方分割ならば))
//データを分割していく処理では、空配列は作らない方が良い(計算量爆発の温床)
//文字列を0-indexedで扱う時、全体の文字数をどう扱うかは最初に決める&忘れない
//場合分けが沢山の時はreturn忘れを確認
//LISは連続とは限らない。
//mintでも0で割っては行けない(例: 関数の合成とかでやりがち assert落ちする)
//負の数を/2してはいけない(それはfloorでないから)
//DPを書く時は、定義を常に明確にする!定義を変えたいと思ったならば、定義が定まるまでは"必要な情報"を考える。
//尺取り法的な事をする時は、rは勿論"lもNを超え無いようにする"事!(違反するとエラーコード139が出たりする)
//無断で0を平方数にカウントする人もいる
//”部分文字列”と”連続部分文字列”は違うので確認すること
//一般のグラフと、有向辺かつその貼り方に制約がある(多くの場合:番号がで解放に伸びる)はだいぶ違うので確認すること
//座標を2で割った時の”切り捨て側(左側)”を求めるには 誤:(x / 2) マイナスの時!!! 正:floor<ll>(x, 2);
//stringでの数字の下から1桁目は 正:S.at(N-1) 誤:S.at(0)
//if(S.at(i) == 1) ← charなのに1...?
// modは取りましたか...?(´・ω・`)
//sortの比較関数は、 a == b ならば falseを返す必要がある(そうで無いとRE(発生しない場合もある))
int main() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << fixed << setprecision(15);
ll T = 1;
//cin >> T;
rep(i, 1, T) {
solve();
}
return 0;
}
Astral__