結果
問題 | No.960 マンハッタン距離3 |
ユーザー | FF256grhy |
提出日時 | 2019-12-23 04:42:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,052 bytes |
コンパイル時間 | 1,969 ms |
コンパイル使用メモリ | 179,840 KB |
実行使用メモリ | 6,912 KB |
最終ジャッジ日時 | 2024-09-15 04:08:28 |
合計ジャッジ時間 | 11,944 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | WA | - |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 3 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 3 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 3 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 2 ms
5,376 KB |
testcase_58 | AC | 2 ms
5,376 KB |
testcase_59 | AC | 2 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | AC | 2 ms
5,376 KB |
testcase_62 | AC | 2 ms
5,376 KB |
testcase_63 | AC | 2 ms
5,376 KB |
testcase_64 | AC | 2 ms
5,376 KB |
testcase_65 | AC | 2 ms
5,376 KB |
testcase_66 | AC | 2 ms
5,376 KB |
testcase_67 | AC | 2 ms
5,376 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 2 ms
5,376 KB |
testcase_70 | AC | 3 ms
5,376 KB |
testcase_71 | AC | 2 ms
5,376 KB |
testcase_72 | AC | 2 ms
5,376 KB |
testcase_73 | AC | 3 ms
5,376 KB |
testcase_74 | AC | 3 ms
5,376 KB |
testcase_75 | AC | 2 ms
5,376 KB |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | AC | 2 ms
5,376 KB |
testcase_78 | AC | 2 ms
5,376 KB |
testcase_79 | AC | 2 ms
5,376 KB |
testcase_80 | AC | 2 ms
5,376 KB |
testcase_81 | AC | 2 ms
5,376 KB |
testcase_82 | AC | 2 ms
5,376 KB |
testcase_83 | AC | 2 ms
5,376 KB |
testcase_84 | AC | 2 ms
5,376 KB |
testcase_85 | AC | 2 ms
5,376 KB |
testcase_86 | AC | 2 ms
5,376 KB |
testcase_87 | AC | 2 ms
5,376 KB |
testcase_88 | AC | 3 ms
5,376 KB |
testcase_89 | AC | 2 ms
5,376 KB |
testcase_90 | AC | 2 ms
5,376 KB |
testcase_91 | AC | 2 ms
5,376 KB |
testcase_92 | AC | 2 ms
5,376 KB |
testcase_93 | AC | 2 ms
5,376 KB |
testcase_94 | AC | 2 ms
5,376 KB |
testcase_95 | AC | 2 ms
5,376 KB |
testcase_96 | AC | 2 ms
5,376 KB |
testcase_97 | AC | 3 ms
5,376 KB |
testcase_98 | AC | 2 ms
5,376 KB |
testcase_99 | AC | 2 ms
5,376 KB |
testcase_100 | AC | 2 ms
5,376 KB |
testcase_101 | AC | 2 ms
5,376 KB |
testcase_102 | AC | 2 ms
5,376 KB |
testcase_103 | AC | 2 ms
5,376 KB |
testcase_104 | AC | 2 ms
5,376 KB |
testcase_105 | AC | 2 ms
5,376 KB |
testcase_106 | AC | 2 ms
5,376 KB |
testcase_107 | AC | 2 ms
5,376 KB |
testcase_108 | AC | 2 ms
5,376 KB |
testcase_109 | AC | 2 ms
5,376 KB |
testcase_110 | AC | 2 ms
5,376 KB |
testcase_111 | AC | 2 ms
5,376 KB |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | AC | 2 ms
5,376 KB |
testcase_117 | AC | 2 ms
5,376 KB |
testcase_118 | AC | 2 ms
5,376 KB |
testcase_119 | AC | 2 ms
5,376 KB |
testcase_120 | AC | 2 ms
5,376 KB |
testcase_121 | AC | 2 ms
5,376 KB |
testcase_122 | AC | 2 ms
5,376 KB |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | AC | 2 ms
5,376 KB |
testcase_125 | AC | 2 ms
5,376 KB |
testcase_126 | AC | 2 ms
5,376 KB |
testcase_127 | AC | 2 ms
5,376 KB |
testcase_128 | WA | - |
testcase_129 | WA | - |
testcase_130 | WA | - |
testcase_131 | WA | - |
testcase_132 | AC | 74 ms
5,376 KB |
testcase_133 | AC | 4 ms
5,376 KB |
testcase_134 | AC | 20 ms
5,376 KB |
testcase_135 | AC | 28 ms
5,376 KB |
testcase_136 | AC | 26 ms
5,376 KB |
testcase_137 | AC | 39 ms
5,376 KB |
testcase_138 | AC | 95 ms
5,888 KB |
testcase_139 | AC | 114 ms
6,528 KB |
testcase_140 | AC | 79 ms
5,376 KB |
testcase_141 | AC | 83 ms
5,376 KB |
testcase_142 | AC | 49 ms
5,376 KB |
testcase_143 | AC | 49 ms
5,376 KB |
testcase_144 | AC | 68 ms
5,376 KB |
testcase_145 | AC | 7 ms
5,376 KB |
testcase_146 | AC | 18 ms
5,376 KB |
testcase_147 | AC | 58 ms
5,376 KB |
testcase_148 | AC | 42 ms
5,376 KB |
testcase_149 | AC | 96 ms
5,504 KB |
testcase_150 | AC | 117 ms
6,912 KB |
testcase_151 | AC | 5 ms
5,376 KB |
testcase_152 | AC | 55 ms
5,376 KB |
testcase_153 | AC | 82 ms
5,376 KB |
testcase_154 | AC | 4 ms
5,376 KB |
testcase_155 | AC | 63 ms
5,376 KB |
testcase_156 | AC | 22 ms
5,376 KB |
testcase_157 | AC | 61 ms
5,376 KB |
testcase_158 | AC | 80 ms
5,376 KB |
testcase_159 | AC | 12 ms
5,376 KB |
testcase_160 | AC | 5 ms
5,376 KB |
testcase_161 | AC | 71 ms
5,376 KB |
testcase_162 | AC | 70 ms
5,376 KB |
testcase_163 | AC | 40 ms
5,376 KB |
testcase_164 | AC | 126 ms
5,760 KB |
testcase_165 | AC | 84 ms
5,376 KB |
testcase_166 | AC | 14 ms
5,376 KB |
testcase_167 | AC | 46 ms
5,376 KB |
testcase_168 | AC | 28 ms
5,376 KB |
testcase_169 | AC | 31 ms
5,376 KB |
testcase_170 | AC | 25 ms
5,376 KB |
testcase_171 | AC | 43 ms
5,376 KB |
testcase_172 | AC | 38 ms
5,376 KB |
testcase_173 | AC | 10 ms
5,376 KB |
testcase_174 | AC | 65 ms
5,376 KB |
testcase_175 | AC | 82 ms
5,376 KB |
testcase_176 | AC | 55 ms
5,376 KB |
testcase_177 | AC | 8 ms
5,376 KB |
testcase_178 | AC | 58 ms
5,376 KB |
testcase_179 | AC | 61 ms
5,376 KB |
testcase_180 | AC | 71 ms
5,376 KB |
testcase_181 | AC | 18 ms
5,376 KB |
testcase_182 | AC | 32 ms
5,376 KB |
testcase_183 | AC | 45 ms
5,376 KB |
testcase_184 | AC | 34 ms
5,376 KB |
testcase_185 | AC | 53 ms
5,376 KB |
testcase_186 | AC | 65 ms
5,376 KB |
testcase_187 | AC | 49 ms
5,376 KB |
testcase_188 | AC | 2 ms
5,376 KB |
testcase_189 | AC | 2 ms
5,376 KB |
testcase_190 | AC | 2 ms
5,376 KB |
testcase_191 | AC | 2 ms
5,376 KB |
testcase_192 | AC | 2 ms
5,376 KB |
testcase_193 | AC | 2 ms
5,376 KB |
testcase_194 | AC | 2 ms
5,376 KB |
testcase_195 | AC | 2 ms
5,376 KB |
testcase_196 | AC | 52 ms
5,376 KB |
testcase_197 | AC | 15 ms
5,376 KB |
testcase_198 | AC | 39 ms
5,376 KB |
testcase_199 | AC | 56 ms
5,376 KB |
testcase_200 | AC | 64 ms
5,376 KB |
testcase_201 | AC | 38 ms
5,376 KB |
testcase_202 | AC | 60 ms
5,376 KB |
testcase_203 | AC | 34 ms
5,376 KB |
testcase_204 | AC | 81 ms
5,376 KB |
testcase_205 | AC | 38 ms
5,376 KB |
testcase_206 | AC | 73 ms
5,376 KB |
testcase_207 | AC | 55 ms
5,376 KB |
testcase_208 | AC | 59 ms
5,376 KB |
testcase_209 | AC | 19 ms
5,376 KB |
testcase_210 | AC | 9 ms
5,376 KB |
testcase_211 | AC | 28 ms
5,376 KB |
testcase_212 | AC | 18 ms
5,376 KB |
testcase_213 | AC | 39 ms
5,376 KB |
testcase_214 | AC | 82 ms
5,376 KB |
testcase_215 | AC | 67 ms
5,376 KB |
testcase_216 | AC | 79 ms
5,376 KB |
testcase_217 | AC | 44 ms
5,376 KB |
testcase_218 | AC | 76 ms
5,376 KB |
testcase_219 | AC | 40 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); ++i) #define incII(i, l, r) for(int i = (l) ; i <= (r); ++i) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i) #define decII(i, l, r) for(int i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); }; auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); }; auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); }; auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); }; auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); }; auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); }; auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; }; LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); } LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } #define bit(b, i) (((b) >> (i)) & 1) #define SI(v) static_cast<int>(v.size()) #define RF(e, v) for(auto & e: v) #define until(e) while(! (e)) #define if_not(e) if(! (e)) #define ef else if #define UR assert(false) // ---- #define inCI(v, l, r) ((l) < (v) && (v) <= (r)) #define inCD(v, l, r) ((l) < (v) && (v) < (r)) #define T0(T) T #define T1(T) vector<T0(T)> #define T2(T) vector<T1(T)> #define V0(v, T ...) v #define V1(v, T, n, ...) T1(T)(n, V0(v, T, __VA_ARGS__)) #define V2(v, T, n, ...) T2(T)(n, V1(v, T, __VA_ARGS__)) int main() { LL h, w, n; cin >> h >> w >> n; vector<LL> a(n), b(n); set<int> parity; inc(i, n) { LL x, y; cin >> x >> y; a[i] = x - y; b[i] = x + y; parity.insert((x + y) % 2); } auto solve = [&]() -> LL { if(SI(parity) == 2) { return 0; } LL INF = 1e12; LL s = +INF, S = -INF; LL t = +INF, T = -INF; inc(i, n) { setmin(s, a[i]); setmax(S, a[i]); setmin(t, b[i]); setmax(T, b[i]); } inc(i, n) { if(inCD(a[i], s, S) && inCD(b[i], t, T)) { return 0; } } auto xy = [](LL a, LL b) -> pair<LL, LL> { assert((a + b) % 2 == 0); return { (b + a) / 2, (b - a) / 2 }; }; auto st = xy(s, t); auto sT = xy(s, T); auto St = xy(S, t); auto ST = xy(S, T); if(s == S && t == T) { return h * w; } if(s == S) { LL x = st.FI, y = st.SE; LL X = ST.FI, Y = ST.SE; X = h + 1 - X; Y = w + 1 - Y; return x * y + X * Y + (n == 2 ? S - s - 1 : 0); } if(t == T) { LL x = st.FI, Y = st.SE; LL X = ST.FI, y = ST.SE; X = h + 1 - X; Y = w + 1 - Y; return x * Y + X * y + (n == 2 ? T - t - 1 : 0); } auto ok = [&](LL x, LL y) -> bool { set<LL> d; inc(i, n) { auto p = xy(a[i], b[i]); d.insert(abs(x - p.FI) + abs(y - p.SE)); } return (SI(d) == 1); }; LL A = S - s, B = T - t, ans = 0; if(A >= B) { LL x = sT.FI, y = ST.SE; LL X = St.FI, Y = st.SE; if(ok(x, y)) { ans += 1; } if(ok(X, Y) && A != B) { ans += 1; } if(ok(x + 1, y + 1) && A != B) { ans += X - x - 1; } if(ok(x - 1, y)) { ans += x - 1; } if(ok(x, y - 1)) { ans += y - 1; } if(ok(X + 1, Y)) { ans += h - X; } if(ok(X, Y + 1)) { ans += w - Y; } } else { LL x = St.FI, y = st.SE; LL X = sT.FI, Y = ST.SE; if(ok(x, Y)) { ans += 1; } if(ok(X, y)) { ans += 1; } if(ok(x + 1, Y - 1)) { ans += X - x - 1; } if(ok(x - 1, Y)) { ans += x - 1; } if(ok(X, y - 1)) { ans += y - 1; } if(ok(X + 1, y)) { ans += h - X; } if(ok(x, Y + 1)) { ans += w - Y; } } return ans; }; cout << solve() << endl; return 0; }