結果
問題 | No.96 圏外です。 |
ユーザー | Astral__ |
提出日時 | 2023-08-09 04:22:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 11,453 bytes |
コンパイル時間 | 3,210 ms |
コンパイル使用メモリ | 238,120 KB |
実行使用メモリ | 110,736 KB |
最終ジャッジ日時 | 2024-11-14 09:44:03 |
合計ジャッジ時間 | 8,391 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 82 ms
97,536 KB |
testcase_01 | AC | 84 ms
97,280 KB |
testcase_02 | AC | 82 ms
97,280 KB |
testcase_03 | WA | - |
testcase_04 | AC | 86 ms
97,920 KB |
testcase_05 | AC | 89 ms
98,176 KB |
testcase_06 | AC | 91 ms
98,304 KB |
testcase_07 | AC | 93 ms
98,480 KB |
testcase_08 | AC | 95 ms
99,072 KB |
testcase_09 | AC | 101 ms
99,584 KB |
testcase_10 | AC | 109 ms
100,352 KB |
testcase_11 | AC | 115 ms
101,120 KB |
testcase_12 | AC | 129 ms
102,400 KB |
testcase_13 | AC | 138 ms
103,040 KB |
testcase_14 | AC | 152 ms
104,576 KB |
testcase_15 | AC | 172 ms
105,728 KB |
testcase_16 | AC | 189 ms
108,080 KB |
testcase_17 | AC | 204 ms
110,464 KB |
testcase_18 | AC | 230 ms
110,208 KB |
testcase_19 | AC | 228 ms
110,256 KB |
testcase_20 | AC | 179 ms
108,348 KB |
testcase_21 | AC | 200 ms
110,736 KB |
testcase_22 | AC | 283 ms
109,984 KB |
testcase_23 | AC | 265 ms
109,884 KB |
testcase_24 | AC | 84 ms
97,536 KB |
testcase_25 | AC | 171 ms
106,624 KB |
testcase_26 | AC | 198 ms
109,440 KB |
testcase_27 | AC | 182 ms
107,776 KB |
ソースコード
#include<bits/stdc++.h> #define PPque priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> #define Pque priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> #define pque priority_queue<int, vector<int>, greater<int>> #define umap unordered_map #define uset unordered_set #define rep(i, s, f) for(ll i = s; i <= f; i++) #define per(i, s, f) for(ll i = s; i >= f; i--) #define all0(x) (x).begin() ,(x).end() #define all(x) (x).begin() + 1, (x).end() #define vvvi vector<vector<vector<int>>> #define vvvl vector<vector<vector<ll>>> #define vvvc vector<vector<vector<char>>> #define vvvd vector<vector<vector<double>>> #define vvi vector<vector<int>> #define vvl vector<vector<ll>> #define vvs vector<vector<string>> #define vvc vector<vector<char>> #define vvp vector<vector<pair<ll, ll>>> #define vvb vector<vector<bool>> #define vvd vector<vector<double>> #define vp vector<pair<ll, ll>> #define vi vector<int> #define vl vector<ll> #define vs vector<string> #define vc vector<char> #define vb vector<bool> #define vd vector<double> #define P pair<ll, ll> #define TU tuple<ll, ll, ll> #define rrr(l, r) mt()%(r-1)+l+1 #define ENDL '\n' #define ull unsigned long long #define debug(a, s) rep(i, s, a.size()-1) {cout << a.at(i) << " ";}cout << endl; #define Debug(a, s) rep(i, s, a.size()-1) {rep(j, s, a.at(i).size()-1) {cout << a.at(i).at(j) << " ";}cout << endl;} typedef long long ll; using namespace std; //////////////////////////////////////////////////////////////////////////////////////////////////////////// //これが本当の組み込み関数ってね(笑) 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済み 存在しない: N . //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済み 存在しない: N return distance(A.begin(), upper_bound(A.begin(), A.end(), x)); } void compress(vector<ll> &A) {//小さい順に順位、大きい順にしたいならreverseはNG最後に変換 vector<ll> temp = A; sort(temp.begin()+1, temp.end()); for (int i = 1; i <= int(A.size()-1); i++) { A.at(i) = distance(temp.begin(), lower_bound(temp.begin()+1, temp.end(), A.at(i))); } } ll LIS1(vl &A) {//at(0)は番兵、広義単調増加 ll N = A.size()-1; vl L(N+1, 1001001001001001001LL); L.at(0) = -1 * 1001001001001001001LL; ll ans = 0; rep(i, 1, N) { ll idx = over<ll>(L, A.at(i)); L.at(idx) = A.at(i); ans = max(ans, idx); } return ans; } ll LIS2(vl &A) {//狭義単調増加 ll N = A.size() - 1; vl L(N+1, 1001001001001001001LL); L.at(0) = -1 * 1001001001001001001LL; ll ans = 0; rep(i, 1, N) { ll idx = or_more<ll>(L, A.at(i)); L.at(idx) = A.at(i); ans = max(ans, idx); } return ans; } ////////////////////////////////////////////////////////////////////// //数学系 /////////////////////////////////////////////////////////////////////// ll POWER(ll a, ll b, ll mod) { a %= mod; vector<ll> pow (61); pow.at(0) = a; bitset<60> bina(b); ll answer = 1; for (int i = 1; i <= 60; i++) { pow.at(i) = pow.at(i-1) * pow.at(i-1) % mod; if (bina.test(i-1)) { answer = (answer*pow.at(i-1)) % mod; } } return answer; } ll Div(ll a, ll b, ll mod) { return a * POWER(b, mod-2, mod) % mod; } ll round(ll x, ll i) { return ll(x + 5 * pow(10, i-1))/ll(pow(10, i)) * ll(pow(10, i)); } template <typename T> //約分 void normalize(T &mol, T &deno) { T mol_temp = abs(mol); T deno_temp = abs(deno); T GCD = gcd(mol_temp, deno_temp); mol /= GCD; deno /= GCD; } vvl mat_mul(vvl &a, vvl &b, ll mod) {//0-indexed && 正方行列 ll n = a.size(); vvl res(n , vl(n, 0)); rep(i, 0, n-1) { rep(j, 0, n-1) { rep(k, 0, n-1) { res.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j); res.at(i).at(j) %= mod; } } } return res; } vvl mat_pow(vvl &a, ll b, ll mod) {//0-indexed && 正方行列 bitset<60> bina(b); vvl power = a; int N = a.size(); vvl res(N, vl(N, 0)); rep(i, 0, N-1) { res.at(i).at(i) = 1; } rep(i, 1, 60) { if (bina.test(i-1)) { res = mat_mul(res, power, mod); } power = mat_mul(power, power, mod); } return res; } vvl comb(ll n, ll mod) {//計算にO(N^2) 読み取りにO(1) vvl v(n+1, vl(n+1, 0)); rep(i, 0, v.size() - 1) { v.at(i).at(0) = 1; v.at(i).at(i) = 1; } rep(i, 1, v.size()-1) { rep(j, 1, i) { v.at(i).at(j) = v.at(i-1).at(j-1) + v.at(i-1).at(j); v.at(i).at(j) %= mod; } } return v; } ll nCk(int n, int k, ll mod) {//毎回O(max(分子、 分母)) ll ue = 1; ll sita = 1; for (int i = 1; i <= k; i++) { sita *= i; sita %= mod; } for (int i = 1; i <= k; i++) { ue *= (n-i+1); ue %= mod; } return Div(ue, sita, mod); } ll gaiseki(P a, P b) { //原点を中心としてaからbの方向 0以下なら角aObが180°以上 return a.first * b.second - a.second * b.first; } ll gaiseki(P a, P b, P c) { //cを中心としてaからbの方向 return (a.first - c.first) * (b.second - c.second) - (a.second - c.second) * (b.first - c.first); } ll nto10(string S, ll base) { ll res = 0; reverse(all0(S)); while(!S.empty()) { ll num = S.back() - '0'; if(num < 0 || num > 9) num = 9 + S.back() - 'a' + 1; res = res * base + num; S.pop_back(); } return res; } string toN(ll N, ll base) { if(N == 0) return "0"; string ans =""; ll MOD = abs(base); while(N != 0) { ll first = N % MOD; while(first < 0) first += MOD; ans += to_string(first); N -= first; N /= base; } reverse(all0(ans)); return ans; } double DIST(P a, P b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); } vp factrization(ll N) { vp res; for (int 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; } struct comb_fast {//must素数 vl fac; vl facinv; vl inv; ll mod_comb; comb_fast (ll n, ll mod) { mod_comb = mod; fac.assign(n+1, 1); facinv.assign(n+1, 1); inv.assign(n+1, 1); rep(i, 2, n) { fac.at(i) = fac.at(i-1) * i % mod_comb; inv.at(i) = mod_comb - inv.at(mod_comb%i) * (mod_comb/i)%mod_comb; facinv.at(i) = facinv.at(i-1) * inv.at(i) % mod_comb; } } ll get(ll n, ll k) { if(n < k) return 0; if(n < 0 || k < 0) return 0; return fac.at(n) * (facinv.at(k) * facinv.at(n-k)%mod_comb)%mod_comb; } }; double KAKUDO(double rad) { double res = rad * 180 / 3.141592653589793; return res; } double RAD(double kakudo) { return kakudo / 180 * 3.141592653589793; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //グローバル変数を置くところ(情報工学意識高め) ll int_max = 1001001001; ll ll_max = 1001001001001001001LL; const double pi = 3.141592653589793; vl dx{0, 1, 0, -1, 0, 1, 1, -1, -1}; vl dy{0, 0, -1, 0, 1, 1, -1, -1, 1}; //#pragma GCC optimize ("-O3") //ll mod = 1000000007; //ll mod = 998244353; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// vp convex(vp &V) { ll N = V.size(); vp res(2 * N); ll k = 0;//k = 次に埋めるidx rep(i, 0, N-1) { while(k >= 2 && gaiseki(V.at(i), res.at(k-2), res.at(k-1)) <= 0) { k--; } res.at(k) = V.at(i); k++; } ll t = k;//これより前だと左側包みを削ってしまう per(i, max(0LL, N-2), 0) { while(k >= t + 1 && gaiseki(V.at(i), res.at(k-2), res.at(k-1)) <= 0) { k--; } res.at(k) = V.at(i); k++; } res.resize(k-1); return res; } struct Union { vector<int> Par; vector<int> size; vector<int> edge; Union(int N) { Par.resize(N+1); for (int i = 1; i <= N; i++) { Par.at(i) = i; } size.assign(N+1, 1); edge.assign(N+1, 0); } int root(int u) { if (Par.at(u) != u) { return Par.at(u) = root(Par.at(u)); } return u; } bool same(int a, int b) { if (root(a) == root(b)) { return true; } return false; } void unit(int a, int b) { int rootA = root(a); int rootB = root(b); if (rootA == rootB) { edge.at(rootA)++; return ; } if (size.at(rootA) < size.at(rootB)) { swap(a, b); rootA = root(a); rootB = root(b); //常にAにBがくっつくようにする } if (size.at(rootA) >= size.at(rootB)) { Par.at(rootB) = rootA; size.at(rootA) += size.at(rootB); edge.at(rootA) += edge.at(rootB); edge.at(rootA) ++; } } }; void solve() { ll N; cin >> N; vl X(N+1); vl Y(N+1); if(N == 1) { cout << 1; return ; } vvvl cnt(2001, vvl(2001, vl())); rep(i, 1, N) { cin >> X.at(i) >> Y.at(i); cnt.at((Y.at(i) + 10000)/10).at((X.at(i) + 10000)/10).push_back(i); } auto dist = [&](P a, P b) { return (a.first - b.first ) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); }; vvp group(N+1, vp()); Union uni(N); rep(i, 1, N) { ll x_idx = (X.at(i) + 10000)/10; ll y_idx = (Y.at(i) + 10000)/10; rep(y, max(0LL, y_idx-1), min(2000LL, y_idx + 1)) { rep(x, max(0LL, x_idx-1), min(2000LL, x_idx + 1)) { for(ll idx : cnt.at(y).at(x)) { if(dist(P(Y.at(i), X.at(i)), P(Y.at(idx), X.at(idx))) <= 100) { uni.unit(idx, i); } } } } } rep(i, 1, N) { group.at(uni.root(i)).push_back(P(Y.at(i), X.at(i))); } rep(i, 1, N) { sort(group.at(i).begin(), group.at(i).end()); } double ans = -1; rep(i, 1, N) { if(group.at(i).size() != 0) { //凸包を計算 //一番遠い点を計算 // ans = max(ans, 一番遠い点 + 2); vp V = convex(group.at(i)); ll n = V.size(); double tooi = -1; rep(j, 0, n-2) { rep(k, j+1, n-1) { tooi = max(tooi, double(dist(V.at(k), V.at(j)))); } } if(V.size() == 1) { tooi = 0; } ans = max(ans, sqrt(tooi) + 2); } } cout << ans << endl; } //stringでの数字の下から1桁目は 正:S.at(N-1) 誤:S.at(0) //if(S.at(i) == 1 ← charなのに1...? // modは取りましたか...?(´・ω・`) int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); solve(); return 0; }