結果
問題 | No.2354 Poor Sight in Winter |
ユーザー | coindarw |
提出日時 | 2023-06-16 23:01:53 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,460 bytes |
コンパイル時間 | 4,407 ms |
コンパイル使用メモリ | 268,420 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 16:04:44 |
合計ジャッジ時間 | 5,364 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using ll = long long; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i) #define rreps(i, n) for (int i = ((int)(n)); i > 0; --i) #define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i) #define repc2(i, s, n) for (int i = (s); i <= (int)(n); ++i) constexpr int inf = 2000'000'000; constexpr ll linf = 4000000000000000000ll; constexpr ll M7 = 1000000007ll; constexpr ll M09 = 1000000009ll; constexpr ll M9 = 998244353ll; #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) using namespace std; using namespace atcoder; template <typename T> inline ostream& operator<<(ostream& os, vector<T>& v) { for (auto& e : v) os << e << " "; return os; } template <typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) noexcept { return os << "(" << p.first << ", " << p.second << ")"; } #ifdef ONLINE_JUDGE #define debug(...) #else #define debug(...) cerr << "<" << #__VA_ARGS__ << ">: ", debug_out(__VA_ARGS__) template <typename T> void debug_out(T t) { cerr << t << endl; } template <typename T, typename... Args> void debug_out(T t, Args... args) { cerr << t << ", "; debug_out(args...); } #endif template <typename T> struct BIT { private: int n, n_; vector<T> data[2]; void add_(int p, int i, T x) { for (; i < n_; i += (i & -i)) data[p][i] += x; } T sum_(int p, int i) { T s(0); for (; i > 0; i -= (i & -i)) s += data[p][i]; return s; } T sum__(int i) { return sum_(0, i + 1) + sum_(1, i + 1) * (i + 1); } public: BIT(int n) : n(n), n_(n + 1) { data[0].resize(n_, 0); data[1].resize(n_, 0); } BIT() {} void add(int l, int r, T x) { assert(0 <= l && l < r && r <= n); add_(0, l + 1, -x * l); add_(0, r + 1, x * r); add_(1, l + 1, x); add_(1, r + 1, -x); } void add(int i, T x) { assert(0 <= i && i < n); add(i, i + 1, x); } T sum(int l, int r) { assert(0 <= l && l < r && r <= n); return sum__(r - 1) - sum__(l - 1); } T get(int i) { assert(0 <= i && i < n); return sum__(i) - sum__(i - 1); } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; using P = pair<int, int>; P _s, _g; cin >> _s.first >> _s.second >> _g.first >> _g.second; P s = {_s.first - _s.second, _s.first + _s.second}; P g = {_g.first - _g.second, _g.first + _g.second}; int minX = min(s.first, g.first), minY = min(s.second, g.second); vector<P> v(n); rep(i, n) { int a, b; cin >> a >> b; v[i] = {a - b, a + b}; minX = min(minX, v[i].first); minY = min(minY, v[i].second); } rep(i, n) { v[i].first -= minX; v[i].second -= minY; } s.first -= minX; s.second -= minY; g.first -= minX; g.second -= minY; int maxX = max(s.first, g.first), maxY = max(s.second, g.second); rep(i, n) { maxX = max(maxX, v[i].first); maxY = max(maxY, v[i].second); } vector<int> vx, vy; auto [sx, sy] = s; auto [gx, gy] = g; vx.push_back(s.first); vx.push_back(g.first); vy.push_back(s.second); vy.push_back(g.second); rep(i, n) { auto [x, y] = v[i]; if (s.first <= x && x <= g.first) vx.push_back(x); if (s.second <= y && y <= g.second) vy.push_back(y); } sort(all(vx)); sort(all(vy)); vx.erase(unique(all(vx)), vx.end()); vy.erase(unique(all(vy)), vy.end()); auto cmp = [&](int p) { int cntX = 0; rep(i, vx.size() - 1) { int d = vx[i + 1] - vx[i]; cntX += (d + p - 1) / p - 1; } int cntY = 0; rep(i, vy.size() - 1) { int d = vy[i + 1] - vy[i]; cntY += (d + p - 1) / p - 1; } return max(cntX, cntY) <= k; }; auto bsearch = [&]() { ll ok = 1000000, ng = 0; while (abs(ng - ok) > 1) { ll mid = (ng + ok) / 2; if (cmp(mid)) ok = mid; else ng = mid; } return ok; }; cout << bsearch() << "\n"; return 0; }