結果

問題 No.960 マンハッタン距離3
ユーザー PachicobuePachicobue
提出日時 2019-12-23 02:03:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 6,780 bytes
コンパイル時間 2,469 ms
コンパイル使用メモリ 216,472 KB
実行使用メモリ 23,936 KB
最終ジャッジ日時 2024-09-14 23:55:12
合計ジャッジ時間 36,957 ms
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 WA -
testcase_39 WA -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 RE -
testcase_45 AC 2 ms
6,940 KB
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 AC 2 ms
6,940 KB
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 RE -
testcase_80 RE -
testcase_81 RE -
testcase_82 RE -
testcase_83 RE -
testcase_84 RE -
testcase_85 RE -
testcase_86 RE -
testcase_87 RE -
testcase_88 RE -
testcase_89 RE -
testcase_90 WA -
testcase_91 WA -
testcase_92 RE -
testcase_93 RE -
testcase_94 WA -
testcase_95 WA -
testcase_96 RE -
testcase_97 RE -
testcase_98 AC 2 ms
6,940 KB
testcase_99 RE -
testcase_100 RE -
testcase_101 RE -
testcase_102 WA -
testcase_103 RE -
testcase_104 RE -
testcase_105 AC 2 ms
6,944 KB
testcase_106 RE -
testcase_107 WA -
testcase_108 RE -
testcase_109 RE -
testcase_110 AC 2 ms
6,940 KB
testcase_111 RE -
testcase_112 RE -
testcase_113 RE -
testcase_114 RE -
testcase_115 RE -
testcase_116 RE -
testcase_117 RE -
testcase_118 RE -
testcase_119 RE -
testcase_120 RE -
testcase_121 RE -
testcase_122 RE -
testcase_123 RE -
testcase_124 RE -
testcase_125 RE -
testcase_126 RE -
testcase_127 RE -
testcase_128 WA -
testcase_129 WA -
testcase_130 WA -
testcase_131 WA -
testcase_132 RE -
testcase_133 RE -
testcase_134 RE -
testcase_135 RE -
testcase_136 RE -
testcase_137 RE -
testcase_138 RE -
testcase_139 RE -
testcase_140 RE -
testcase_141 RE -
testcase_142 RE -
testcase_143 RE -
testcase_144 RE -
testcase_145 RE -
testcase_146 WA -
testcase_147 WA -
testcase_148 RE -
testcase_149 RE -
testcase_150 AC 92 ms
13,184 KB
testcase_151 AC 4 ms
6,944 KB
testcase_152 RE -
testcase_153 AC 113 ms
16,128 KB
testcase_154 RE -
testcase_155 RE -
testcase_156 RE -
testcase_157 RE -
testcase_158 RE -
testcase_159 RE -
testcase_160 RE -
testcase_161 RE -
testcase_162 RE -
testcase_163 RE -
testcase_164 RE -
testcase_165 RE -
testcase_166 RE -
testcase_167 RE -
testcase_168 RE -
testcase_169 RE -
testcase_170 RE -
testcase_171 RE -
testcase_172 RE -
testcase_173 RE -
testcase_174 RE -
testcase_175 RE -
testcase_176 RE -
testcase_177 RE -
testcase_178 RE -
testcase_179 RE -
testcase_180 AC 195 ms
23,936 KB
testcase_181 AC 25 ms
7,552 KB
testcase_182 AC 71 ms
12,288 KB
testcase_183 AC 107 ms
16,640 KB
testcase_184 AC 70 ms
13,056 KB
testcase_185 AC 133 ms
18,432 KB
testcase_186 AC 179 ms
22,400 KB
testcase_187 AC 114 ms
17,280 KB
testcase_188 RE -
testcase_189 RE -
testcase_190 RE -
testcase_191 RE -
testcase_192 RE -
testcase_193 RE -
testcase_194 RE -
testcase_195 RE -
testcase_196 RE -
testcase_197 RE -
testcase_198 WA -
testcase_199 WA -
testcase_200 RE -
testcase_201 AC 37 ms
8,960 KB
testcase_202 WA -
testcase_203 WA -
testcase_204 RE -
testcase_205 RE -
testcase_206 AC 102 ms
14,840 KB
testcase_207 RE -
testcase_208 RE -
testcase_209 RE -
testcase_210 WA -
testcase_211 WA -
testcase_212 RE -
testcase_213 AC 39 ms
8,960 KB
testcase_214 WA -
testcase_215 WA -
testcase_216 RE -
testcase_217 RE -
testcase_218 AC 94 ms
15,264 KB
testcase_219 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// created [2019/12/23] 00:51:38
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-conversion"

using i32   = int32_t;
using i64   = int64_t;
using u32   = uint32_t;
using u64   = uint64_t;
using uint  = unsigned int;
using usize = std::size_t;
using ll    = long long;
using ull   = unsigned long long;
using ld    = long double;
template<typename T, usize n>
using arr = T (&)[n];
template<typename T, usize n>
using c_arr = const T (&)[n];
template<typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T msbp1(const T u) { return log2p1(u); }
template<typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); }
template<typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); }
template<typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; }
template<typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); }
template<typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); }
template<typename T> constexpr bool btest(const T mask, const usize ind) { return static_cast<bool>((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); }
template<typename T> void bset(T& mask, const usize ind) { mask |= (static_cast<T>(1) << ind); }
template<typename T> void breset(T& mask, const usize ind) { mask &= ~(static_cast<T>(1) << ind); }
template<typename T> void bflip(T& mask, const usize ind) { mask ^= (static_cast<T>(1) << ind); }
template<typename T> void bset(T& mask, const usize ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); }
template<typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); }
template<typename T> bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); }
template<typename T> bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); }
constexpr unsigned int mod                  = 1000000007;
template<typename T> constexpr T inf_v      = std::numeric_limits<T>::max() / 4;
template<typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884};
auto mfp = [](auto&& f) { return [=](auto&&... args) { return f(f, std::forward<decltype(args)>(args)...); }; };

template<typename T>
T in()
{
    T v;
    return std::cin >> v, v;
}
template<typename T, typename Uint, usize n, usize i>
T in_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type) { return in<T>(); }
template<typename T, typename Uint, usize n, usize i>
auto in_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type& szs)
{
    const usize s = (usize)szs[i];
    std::vector<decltype(in_v<T, Uint, n, i + 1>(szs))> ans(s);
    for (usize j = 0; j < s; j++) { ans[j] = in_v<T, Uint, n, i + 1>(szs); }
    return ans;
}
template<typename T, typename Uint, usize n>
auto in_v(c_arr<Uint, n> szs) { return in_v<T, Uint, n, 0>(szs); }
template<typename... Types>
auto in_t() { return std::tuple<std::decay_t<Types>...>{in<Types>()...}; }
struct io_init
{
    io_init()
    {
        std::cin.tie(nullptr), std::ios::sync_with_stdio(false);
        std::cout << std::fixed << std::setprecision(20);
    }
    void clear()
    {
        std::cin.tie(), std::ios::sync_with_stdio(true);
    }
} io_setting;

template<typename T>
int out(const T& v) { return std::cout << v, 0; }
template<typename T>
int out(const std::vector<T>& v)
{
    for (usize i = 0; i < v.size(); i++) {
        if (i > 0) { std::cout << ' '; }
        out(v[i]);
    }
    return std::cout << "\n", 0;
}
template<typename T1, typename T2>
int out(const std::pair<T1, T2>& v) { return out(v.first), std::cout << ' ', out(v.second), 0; }
template<typename T, typename... Args>
int out(const T& v, const Args... args) { return out(v), std::cout << ' ', out(args...), 0; }
template<typename... Args>
int outln(const Args... args) { return out(args...), std::cout << '\n', 0; }
template<typename... Args>
void outel(const Args... args) { return out(args...), std::cout << std::endl, 0; }
#    define SHOW(...) static_cast<void>(0)
constexpr ull TEN(const usize n) { return n == 0 ? 1ULL : TEN(n - 1) * 10ULL; }

template<typename T, typename Uint, usize n, usize i>
auto make_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type, const T& v = T{}) { return v; }
template<typename T, typename Uint, usize n, usize i>
auto make_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type szs, const T& v = T{})
{
    const usize s = (usize)szs[i];
    return std::vector<decltype(make_v<T, Uint, n, i + 1>(szs, v))>(s, make_v<T, Uint, n, i + 1>(szs, v));
}
template<typename T, typename Uint, usize n>
auto make_v(c_arr<Uint, n> szs, const T& t = T{}) { return make_v<T, Uint, n, 0>(szs, t); }
int main()
{
    auto [W, H]  = in_t<ll, ll>();
    const auto N = in<int>();
    std::vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) { x[i] = in<ll>(), y[i] = in<ll>(); }
    if (N <= 12) {
        assert(false);
        // やる
    }

    std::map<ll, std::vector<int>> x_p_y;
    std::map<ll, std::vector<int>> x_m_y;
    for (int i = 0; i < N; i++) {
        x_p_y[x[i] + y[i]].push_back(i);
        x_m_y[x[i] - y[i]].push_back(i);
    }
    std::vector<int> v;
    bool plus = false;
    for (const auto& p : x_p_y) {
        if (p.second.size() >= 3 and v.empty()) { v = p.second, plus = false; }
    }
    for (const auto& p : x_p_y) {
        if (p.second.size() >= 3 and v.empty()) { v = p.second, plus = true; }
    }
    if (v.empty()) { return outln(0); }
    if (v.size() == N) {
        ll xmin = inf_v<ll>, xmax = -inf_v<ll>;
        ll ymin = inf_v<ll>, ymax = -inf_v<ll>;
        for (const int i : v) {
            chmin(xmin, x[i]), chmax(xmax, x[i]);
            chmin(ymin, y[i]), chmax(ymax, y[i]);
        }
        if (plus) {
            return outln(xmin * ymin + (W - xmax + 1) * (H - ymax + 1) + (xmax - xmin - 1));
        } else {
            return outln((W - xmax + 1) * ymin + xmin * (H - ymax + 1) + (xmax - xmin - 1));
        }
    } else {
        std::vector<bool> is_in_v(N, false);
        for (const int i : v) { is_in_v[i] = true; }
        int vout_i = 0;
        for (vout_i = 0; vout_i < N; vout_i++) {
            if (not is_in_v[vout_i]) { break; }
        }
        const ll vout_x = x[vout_i], vout_y = y[vout_i];
        assert(false);
        // やる
    }

    return 0;
}
0