結果
| 問題 |
No.3042 拡大コピー
|
| コンテスト | |
| ユーザー |
Nauclhlt🪷
|
| 提出日時 | 2025-01-09 22:51:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 23,235 bytes |
| コンパイル時間 | 2,963 ms |
| コンパイル使用メモリ | 240,804 KB |
| 実行使用メモリ | 13,980 KB |
| 最終ジャッジ日時 | 2025-03-01 07:38:09 |
| 合計ジャッジ時間 | 4,934 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 24 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
template <typename T>
struct Edge
{
int From;
int To;
T Weight;
public:
Edge(int from, int to, T weight)
{
From = from;
To = to;
Weight = weight;
}
};
struct Point
{
public:
int X;
int Y;
Point(int x, int y)
{
X = x;
Y = y;
}
friend bool operator==(Point left, Point right)
{
return left.X == right.X && left.Y == right.Y;
}
friend bool operator<(Point left, Point right)
{
return tie(left.X, left.Y) < tie(right.X, right.Y);
}
};
struct PointHash
{
size_t operator()(Point point)
{
return hash<int>()(point.X) ^ hash<int>()(point.Y);
}
};
template <typename T>
struct RunLengthElement
{
public:
int Count;
int StartIndex;
T Value;
RunLengthElement(int startIndex, int count, T value)
{
StartIndex = startIndex;
Count = count;
Value = value;
}
};
template <typename T>
bool reverseCompare(T a, T b)
{
return a > b;
}
vector<int> vectorInt(int n)
{
vector<int> res;
res.reserve(n);
for (int i = 0; i < n; i++)
{
int v;
cin >> v;
res.push_back(v);
}
return res;
}
vector<ll> vectorLong(int n)
{
vector<ll> res;
res.reserve(n);
for (int i = 0; i < n; i++)
{
ll v;
cin >> v;
res.push_back(v);
}
return res;
}
vector<string> vectorString(int n)
{
vector<string> res;
res.reserve(n);
for (int i = 0; i < n; i++)
{
string v;
cin >> v;
res.push_back(v);
}
return res;
}
int combination(int n, int r)
{
int c = 1;
for (int i = 1; i <= r; i++)
{
c = c * (n - i + 1) / i;
}
return c;
}
ll combination(ll n, ll r)
{
ll c = 1;
for (ll i = 1; i <= r; i++)
{
c = c * (n - i + 1) / i;
}
return c;
}
ll pow(ll b, ll exp)
{
if (exp == 0) return 1L;
if (exp == 1) return b;
ll m = pow(b, exp / 2L);
m *= m;
if (exp % 2L == 1) m *= b;
return m;
}
ll modpow(ll b, ll exp, ll mod)
{
if (exp == 0) return 1;
if (exp == 1) return b % mod;
ll m = modpow(b, exp / 2L, mod);
m *= m;
m %= mod;
if (exp % 2L == 1) m *= b % mod;
m %= mod;
return m;
}
ll modinv( ll a, ll mod )
{
ll b = mod, u = 1, v = 0;
while ( b > 0 )
{
ll t = a / b;
a -= t * b; swap( a, b );
u -= t * v; swap( u, v );
}
u %= mod;
if (u < 0) u += mod;
return u;
}
// ax ≡ b (mod m)なる最小のxを求める
optional<ll> solveModLinear(ll a, ll b, ll m)
{
long gcd = __gcd(__gcd(a, b), m);
a /= gcd;
b /= gcd;
m /= gcd;
if (__gcd(a, m) == 1)
{
long inv = modinv(a, m);
return make_optional((b * inv) % m);
}
return optional<ll>();
}
inline void YesNo(bool t)
{
cout << (t ? "Yes" : "No") << endl;
}
inline void YESNO(bool t)
{
cout << (t ? "YES" : "NO") << endl;
}
inline void yesno(bool t)
{
cout << (t ? "yes" : "no") << endl;
}
inline bool checkBit(int bit, int n)
{
return ((1 << n) & bit) != 0;
}
map<char, int> cntCharOcc(string s)
{
map<char, int> dict;
for (int i = 0; i < (int)s.size(); i++)
{
if (dict.find(s[i]) != dict.end())
{
dict[s[i]] += 1;
}
else
{
dict[s[i]] = 1;
}
}
return dict;
}
template<typename T> bool chmin(T& a, T b)
{
if(a > b)
{
a = b;
return true;
}
return false;
}
template<typename T> bool chmax(T& a, T b)
{
if(a < b)
{
a = b;
return true;
}
return false;
}
int get_random(int min, int max)
{
max--;
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<> rand(min, max);
return rand(mt);
}
template <typename T>
void shuffle(vector<T>& array)
{
for (int i = (int)array.size() - 1; i > 0; i--)
{
int index = get_random(0, i + 1);
swap(array[index], array[i]);
}
}
template <typename T>
vector<int> compressCoords(vector<T>& array)
{
vector<T> sorted = array;
sort(sorted.begin(), sorted.end());
auto r = unique(sorted.begin(), sorted.end());
sorted.erase(r, sorted.end());
vector<int> result(array.size());
for (int i = 0; i < (int)array.size(); i++)
{
result[i] = lower_bound(sorted.begin(), sorted.end(), array[i]) - sorted.begin();
}
return result;
}
template <class _ForwardIterator>
vector<RunLengthElement<typename iterator_traits<_ForwardIterator>::value_type>> compressRunLength(_ForwardIterator first, _ForwardIterator last)
{
vector<RunLengthElement<typename iterator_traits<_ForwardIterator>::value_type>> list;
int count = 1;
int start = 0;
typename iterator_traits<_ForwardIterator>::value_type prev = *first;
int curIndex = 1;
first++;
for (auto it = first; it != last; ++it)
{
if (prev == *it)
{
count++;
}
else
{
list.push_back(RunLengthElement<typename iterator_traits<_ForwardIterator>::value_type>(start, count, prev));
start = curIndex;
count = 1;
}
prev = *it;
curIndex++;
}
list.push_back(RunLengthElement<typename iterator_traits<_ForwardIterator>::value_type>(start, count, prev));
return list;
}
template <typename T>
vector<T> decompressRunLength(vector<RunLengthElement<T>>& source)
{
vector<T> res;
for (int i = 0; i < (int)source.size(); i++)
{
for (int j = 0; j < source[i].Count; j++)
{
res.push_back(source[i].Value);
}
}
return res;
}
template <class _ForwardIterator>
void print(_ForwardIterator first, _ForwardIterator last)
{
bool f = true;
for (auto it = first; it != last; ++it)
{
if (!f)
{
cout << " ";
}
cout << *it;
f = false;
}
cout << endl;
}
void print01(bool t)
{
cout << (t ? "1" : "0") << endl;
}
bool isSquareNumber(ll n)
{
ll q = (ll)floor(sqrt(n));
return q * q == n;
}
// 最初から貼っとくライブラリ
template <typename T>
class PrefixSum
{
private:
vector<T> _sums;
public:
PrefixSum(vector<T>& sequence)
{
_sums.resize(sequence.size() + 1);
_sums[0] = 0;
for (int i = 0; i < (int)sequence.size(); i++)
{
_sums[i + 1] = _sums[i] + sequence[i];
}
}
T Sum(int l, int r)
{
return _sums[r] - _sums[l];
}
T AllSum()
{
return _sums[_sums.size() - 1];
}
vector<T>& GetArray()
{
return _sums;
}
};
template <typename T>
class PrefixSum2D
{
private:
vector<vector<T>> _sums;
public:
PrefixSum2D(vector<vector<T>>& sequence)
{
int height = sequence.size();
int width = sequence[0].size();
_sums.resize(height + 1, vector<T>(width + 1, 0));
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
_sums[y + 1][x + 1] = _sums[y + 1][x] + _sums[y][x + 1] - _sums[y][x] + sequence[y][x];
}
}
}
T Sum(int startX, int startY, int endX, int endY)
{
return _sums[endY][endX] + _sums[startY][startX] - _sums[startY][endX] - _sums[endY][startX];
}
T AllSum()
{
return _sums[(int)_sums.size() - 1][(int)_sums[0].size() - 1];
}
};
class UnionFind
{
private:
vector<int> _parents;
vector<int> _size;
int _vertexCount;
public:
UnionFind(int n)
{
_vertexCount = n;
_parents.resize(n);
_size.resize(n);
for (int i = 0; i < n; i++)
{
_size[i] = 1;
_parents[i] = i;
}
}
int Root(int x)
{
if (_parents[x] == x) return x;
return _parents[x] = Root(_parents[x]);
}
int Size(int x)
{
return _size[Root(x)];
}
void Unite(int x, int y)
{
int rootX = Root(x);
int rootY = Root(y);
if (rootX == rootY) return;
int from = rootX;
int to = rootY;
if (_size[from] > _size[to])
{
swap(from, to);
}
_size[to] += _size[from];
_parents[from] = to;
}
vector<int> Find(int x)
{
int root = Root(x);
vector<int> set;
for (int i = 0; i < _vertexCount; i++)
{
if (Root(i) == root)
{
set.push_back(i);
}
}
return set;
}
unordered_map<int, vector<int>> FindAll()
{
unordered_map<int, vector<int>> sets;
for (int i = 0; i < _vertexCount; i++)
{
int root = Root(i);
if (sets.find(root) != sets.end())
{
sets[root].push_back(i);
}
else
{
sets.emplace(root, vector<int>());
sets[root].push_back(i);
}
}
return sets;
}
bool Same(int x, int y)
{
int rootX = Root(x);
int rootY = Root(y);
return rootX == rootY;
}
void Clear()
{
for (int i = 0; i < _vertexCount; i++)
{
_parents[i] = i;
_size[i] = 1;
}
}
int VertexCount()
{
return _vertexCount;
}
};
template <typename T>
class Imos
{
private:
vector<T> _data;
public:
Imos(int length)
{
_data.resize(length, 0);
}
Imos(vector<T>& array)
{
_data = array;
}
void AddQueryLen(int start, int length, T value)
{
AddQuery(start, start + length, value);
}
void AddQuery(int start, int end, T value)
{
_data[start] += value;
if (end < (int)_data.size())
{
_data[end] -= value;
}
}
void Accumulate()
{
for (int i = 1; i < (int)_data.size(); i++)
{
_data[i] += _data[i - 1];
}
}
vector<T> GetData()
{
return _data;
}
};
template <typename T>
class Imos2D
{
private:
vector<vector<T>> _data;
int _width;
int _height;
public:
Imos2D(vector<vector<T>> data)
{
_data = data;
_height = data.size();
_width = data[0].size();
}
Imos2D(int h, int w)
{
_data.resize(h, vector<T>(w, 0));
_width = w;
_height = h;
}
void AddQuery(int startX, int startY, int endX, int endY, T value)
{
_data[startY][startX] += value;
if (endX < _width)
{
_data[startY][endX] -= value;
}
if (endY < _height)
{
_data[endY][startX] -= value;
}
if (endX < _width && endY < _height)
{
_data[endY][endX] += value;
}
}
void AddQueryLen(int x, int y, int w, int h, T value)
{
AddQuery(x, y, x + w, y + h, value);
}
void Accumulate()
{
for (int x = 1; x < _width; x++)
{
for (int y = 0; y < _height; y++)
{
_data[y][x] += _data[y][x - 1];
}
}
for (int y = 1; y < _height; y++)
{
for (int x = 0; x < _width; x++)
{
_data[y][x] += _data[y - 1][x];
}
}
}
vector<vector<T>> GetData()
{
return _data;
}
};
template<typename T, T OP(T, T), T APPLY(T, T)>
class SegmentTree
{
private:
int _treeSize;
int _dataSize;
int _originalDataSize;
vector<T> _data;
T _identity;
public:
SegmentTree(int n, T identity)
{
_originalDataSize = n;
_identity = identity;
int size = 1;
while (n > size)
{
size <<= 1;
}
_dataSize = size;
_treeSize = 2 * size - 1;
_data.resize(_treeSize, _identity);
}
int OriginalDataSize()
{
return _originalDataSize;
}
int TreeSize()
{
return _treeSize;
}
T Identity()
{
return _identity;
}
void Build(vector<T>& array)
{
if (_originalDataSize != (int)array.size())
{
throw exception();
}
for (int i = 0; i < (int)array.size(); i++)
{
_data[i + _dataSize - 1] = array[i];
}
for (int i = _dataSize - 2; i >= 0; i--)
{
_data[i] = OP(_data[(i << 1) + 1], _data[(i << 1) + 2]);
}
}
void Apply(int index, T value)
{
index += _dataSize - 1;
_data[index] = APPLY(_data[index], value);
while (index > 0)
{
index = (index - 1) >> 1;
_data[index] = OP(_data[(index << 1) + 1], _data[(index << 1) + 2]);
}
}
T Query(int left, int right)
{
return QueryRec(left, right, 0, 0, _dataSize);
}
const T& operator[](size_t index) const
{
return _data[_dataSize - 1 + index];
}
T& operator[](size_t index)
{
return _data[_dataSize - 1 + index];
}
private:
T QueryRec(int left, int right, int index, int l, int r)
{
if (left >= r || right <= l)
{
return _identity;
}
if (left <= l && r <= right)
{
return _data[index];
}
return OP(QueryRec(left, right, (index << 1) + 1, l, (l + r) / 2), QueryRec(left, right, (index << 1) + 2, (l + r) / 2, r));
}
};
template <typename T, typename M, T OP(T, T), T MAPPING(T, M, int), T COMPOSITION(T, T)>
class LazySegmentTree
{
private:
int _treeSize;
int _dataSize;
int _originalDataSize;
vector<T> _data;
vector<optional<T>> _lazy;
T _identity;
public:
LazySegmentTree(int n, T identity)
{
_originalDataSize = n;
_identity = identity;
int size = 1;
while (n > size)
{
size <<= 1;
}
_dataSize = size;
_treeSize = 2 * size - 1;
_data.resize(_treeSize, _identity);
_lazy.resize(_treeSize, nullopt);
}
void Build(vector<T>& array)
{
if (_originalDataSize != (int)array.size())
{
throw exception();
}
for (int i = 0; i < (int)array.size(); i++)
{
_data[i + _dataSize - 1] = array[i];
}
for (int i = _dataSize - 2; i >= 0; i--)
{
_data[i] = OP(_data[(i << 1) + 1], _data[(i << 1) + 2]);
}
}
int TreeSize()
{
return _treeSize;
}
int OriginalDataSize()
{
return _originalDataSize;
}
void Apply(int left, int right, M m)
{
ApplyRec(left, right, m, 0, 0, _dataSize);
}
T Query(int left, int right)
{
return QueryRec(left, right, 0, 0, _dataSize);
}
T GetByIndex(int index)
{
if (index < 0 || index >= _originalDataSize)
{
throw exception();
}
return AccessRec(index, 0, 0, _dataSize);
}
private:
void Evaluate(int index, int l, int r)
{
if (!_lazy[index].has_value())
{
return;
}
if (index < _dataSize - 1)
{
_lazy[(index << 1) + 1] = GuardComposition(_lazy[(index << 1) + 1], _lazy[index]);
_lazy[(index << 1) + 2] = GuardComposition(_lazy[(index << 1) + 2], _lazy[index]);
}
_data[index] = MAPPING(_data[index], _lazy[index].value(), r - l);
_lazy[index] = nullopt;
}
optional<M> GuardComposition(optional<M> a, optional<M> b)
{
if (!a.has_value())
{
return b;
}
else
{
return COMPOSITION(a.value(), b.value());
}
}
void ApplyRec(int left, int right, M m, int index, int l, int r)
{
Evaluate(index, l, r);
if (left <= l && r <= right)
{
_lazy[index] = GuardComposition(_lazy[index], m);
Evaluate(index, l, r);
}
else if (left < r && l < right)
{
ApplyRec(left, right, m, (index << 1) + 1, l, (l + r) / 2);
ApplyRec(left, right, m, (index << 1) + 2, (l + r) / 2, r);
_data[index] = OP(_data[(index << 1) + 1], _data[(index << 1) + 2]);
}
}
T QueryRec(int left, int right, int index, int l, int r)
{
Evaluate(index, l, r);
if (left >= r || right <= l)
{
return _identity;
}
if (left <= l && r <= right)
{
return _data[index];
}
return OP(QueryRec(left, right, (index << 1) + 1, l, (l + r) / 2), QueryRec(left, right, (index << 1) + 2, (l + r) / 2, r));
}
T AccessRec(int target, int index, int l, int r)
{
Evaluate(index, l, r);
if (index >= _dataSize - 1)
{
return _data[index];
}
int mid = (l + r) / 2;
if (target < mid)
{
return AccessRec(target, (index << 1) + 1, l, mid);
}
else
{
return AccessRec(target, (index << 1) + 2, mid, r);
}
}
};
#define CONST_MOD 998244353LL
//#define CONST_MOD 1000000007LL
struct ModInt
{
long long Value;
public:
ModInt()
{
Value = 0L;
}
ModInt(long long value)
{
Value = value;
}
ModInt Power(long long exp) const
{
if (exp <= -1L)
{
return ModInt(1L) / Power(-exp);
}
if (exp == 0L)
return 1L;
if (exp == 1L)
return *this;
ModInt m = Power(exp / 2L);
m = m * m;
if (exp % 2L == 1L)
{
m = m * (*this);
}
return m;
}
ModInt Inv() const
{
return this->Power(CONST_MOD - 2L);
}
ModInt operator+() const
{
return *this;
}
ModInt operator-() const
{
return ModInt(-Value);
}
friend ModInt operator+(const ModInt& left, const ModInt& right)
{
return ModInt(SafeMod(left.Value + right.Value));
}
friend ModInt operator+(const ModInt& left, const long long& right)
{
return ModInt(SafeMod(left.Value + right));
}
friend ModInt operator+(const long long& left, const ModInt& right)
{
return ModInt(SafeMod(left + right.Value));
}
ModInt& operator+=(const ModInt& x)
{
Value += x.Value;
Value = SafeMod(Value);
return *this;
}
ModInt& operator+=(const long long& x)
{
Value += x;
Value = SafeMod(Value);
return *this;
}
friend ModInt operator-(const ModInt& left, const ModInt& right)
{
return ModInt(SafeMod(left.Value - right.Value));
}
friend ModInt operator-(const ModInt& left, const long long& right)
{
return ModInt(SafeMod(left.Value - right));
}
friend ModInt operator-(const long long& left, const ModInt& right)
{
return ModInt(SafeMod(left - right.Value));
}
ModInt& operator-=(const ModInt& x)
{
Value -= x.Value;
Value = SafeMod(Value);
return *this;
}
ModInt& operator-=(const long long& x)
{
Value -= x;
Value = SafeMod(Value);
return *this;
}
friend ModInt operator*(const ModInt& left, const ModInt& right)
{
return ModInt(SafeMod(left.Value * right.Value));
}
friend ModInt operator*(const ModInt& left, const long long& right)
{
return ModInt(SafeMod(left.Value * right));
}
friend ModInt operator*(const long long& left, const ModInt& right)
{
return ModInt(SafeMod(left * right.Value));
}
ModInt& operator*=(const ModInt& x)
{
Value *= x.Value;
Value = SafeMod(Value);
return *this;
}
ModInt& operator*=(const long long& x)
{
Value *= x;
Value = SafeMod(Value);
return *this;
}
friend ModInt operator /(const ModInt& left, const ModInt& right)
{
ModInt inv = right.Inv();
return ModInt(SafeMod(left.Value * inv.Value));
}
friend ModInt operator/(const ModInt& left, const long long& right)
{
return ModInt(SafeMod(left.Value * ModInt(right).Inv().Value));
}
friend ModInt operator/(const long long& left, const ModInt& right)
{
return ModInt(SafeMod(left * right.Inv().Value));
}
ModInt& operator/=(const ModInt& x)
{
Value *= x.Inv().Value;
Value = SafeMod(Value);
return *this;
}
ModInt& operator/=(const long long& x)
{
Value *= ModInt(x).Inv().Value;
Value = SafeMod(Value);
return *this;
}
ModInt& operator++()
{
++Value;
Value = SafeMod(Value);
return *this;
}
ModInt operator++(int)
{
ModInt temp = *this;
Value++;
Value = SafeMod(Value);
return temp;
}
ModInt& operator--()
{
--Value;
Value = SafeMod(Value);
return *this;
}
ModInt operator--(int)
{
ModInt temp = *this;
Value--;
Value = SafeMod(Value);
return temp;
}
inline static ModInt One()
{
return ModInt(1L);
}
static ModInt Combination(long long n, long long r)
{
ModInt c = 1L;
for (ModInt i = 1; i.Value <= r; i++)
{
c = c * (ModInt(n) - i + ModInt::One()) / i;
}
return c;
}
private:
inline static long long SafeMod(long long a)
{
a %= CONST_MOD;
if (a < 0)
{
a += CONST_MOD;
}
return a;
}
};
//
double dist(pair<double, double> a, pair<double, double> b)
{
return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<pair<double, double>> a;
vector<pair<double, double>> b;
for (int i = 0; i < N; i++)
{
double x, y;
cin >> x >> y;
a.emplace_back(x, y);
}
for (int i = 0; i < N; i++)
{
double x, y;
cin >> x >> y;
b.emplace_back(x, y);
}
double avx = 0, avy = 0, avu = 0, avv = 0;
for (int i = 0; i < N; i++)
{
avx += 1.0 / a[i].first;
avy += 1.0 / a[i].second;
avu += 1.0 / b[i].first;
avv += 1.0 / b[i].second;
}
pair<double, double> ave1 = make_pair(1.0 / avx, 1.0 / avy);
pair<double, double> ave2 = make_pair(1.0 / avu, 1.0 / avv);
double s1 = 0, s2 = 0;
for (int i = 0; i < N; i++)
{
s1 += dist(ave1, a[i]);
s2 += dist(ave2, b[i]);
}
double ans = s2 / s1;
cout << setprecision(20) << ans << endl;
}
Nauclhlt🪷