結果

問題 No.960 マンハッタン距離3
ユーザー risujirohrisujiroh
提出日時 2019-12-23 01:06:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,078 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 174,788 KB
実行使用メモリ 11,040 KB
最終ジャッジ日時 2023-10-12 23:56:53
合計ジャッジ時間 12,986 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,352 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
4,348 KB
testcase_30 WA -
testcase_31 AC 1 ms
4,352 KB
testcase_32 AC 2 ms
4,352 KB
testcase_33 AC 2 ms
4,352 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 1 ms
4,352 KB
testcase_36 WA -
testcase_37 AC 2 ms
4,348 KB
testcase_38 WA -
testcase_39 AC 2 ms
4,348 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
4,356 KB
testcase_45 AC 1 ms
4,352 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 AC 1 ms
4,348 KB
testcase_48 AC 1 ms
4,352 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 2 ms
4,352 KB
testcase_51 AC 2 ms
4,352 KB
testcase_52 AC 2 ms
4,352 KB
testcase_53 AC 2 ms
4,352 KB
testcase_54 AC 1 ms
4,348 KB
testcase_55 AC 1 ms
4,352 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 1 ms
4,348 KB
testcase_62 AC 2 ms
4,348 KB
testcase_63 AC 2 ms
4,352 KB
testcase_64 AC 2 ms
4,352 KB
testcase_65 WA -
testcase_66 AC 2 ms
4,348 KB
testcase_67 AC 2 ms
4,348 KB
testcase_68 AC 1 ms
4,352 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 AC 2 ms
4,348 KB
testcase_73 AC 1 ms
4,348 KB
testcase_74 AC 2 ms
4,348 KB
testcase_75 AC 2 ms
4,348 KB
testcase_76 AC 2 ms
4,348 KB
testcase_77 AC 1 ms
4,348 KB
testcase_78 AC 2 ms
4,348 KB
testcase_79 AC 1 ms
4,352 KB
testcase_80 AC 2 ms
4,352 KB
testcase_81 AC 2 ms
4,356 KB
testcase_82 AC 2 ms
4,348 KB
testcase_83 AC 2 ms
4,348 KB
testcase_84 AC 2 ms
4,348 KB
testcase_85 AC 2 ms
4,348 KB
testcase_86 AC 1 ms
4,352 KB
testcase_87 AC 1 ms
4,352 KB
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 2 ms
4,348 KB
testcase_93 AC 2 ms
4,348 KB
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 AC 2 ms
4,348 KB
testcase_99 AC 2 ms
4,348 KB
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 AC 2 ms
4,348 KB
testcase_104 AC 2 ms
4,352 KB
testcase_105 AC 2 ms
4,348 KB
testcase_106 WA -
testcase_107 WA -
testcase_108 WA -
testcase_109 WA -
testcase_110 AC 1 ms
4,352 KB
testcase_111 AC 2 ms
4,352 KB
testcase_112 AC 1 ms
4,348 KB
testcase_113 AC 2 ms
4,348 KB
testcase_114 AC 1 ms
4,352 KB
testcase_115 AC 2 ms
4,348 KB
testcase_116 AC 1 ms
4,348 KB
testcase_117 AC 2 ms
4,348 KB
testcase_118 AC 2 ms
4,356 KB
testcase_119 AC 2 ms
4,352 KB
testcase_120 AC 1 ms
4,348 KB
testcase_121 AC 1 ms
4,348 KB
testcase_122 AC 2 ms
4,348 KB
testcase_123 AC 2 ms
4,352 KB
testcase_124 AC 2 ms
4,352 KB
testcase_125 AC 2 ms
4,348 KB
testcase_126 AC 2 ms
4,352 KB
testcase_127 AC 2 ms
4,352 KB
testcase_128 WA -
testcase_129 WA -
testcase_130 AC 32 ms
6,928 KB
testcase_131 AC 58 ms
10,256 KB
testcase_132 WA -
testcase_133 WA -
testcase_134 AC 3 ms
4,352 KB
testcase_135 WA -
testcase_136 WA -
testcase_137 AC 3 ms
4,608 KB
testcase_138 WA -
testcase_139 WA -
testcase_140 AC 4 ms
6,140 KB
testcase_141 WA -
testcase_142 WA -
testcase_143 AC 3 ms
4,888 KB
testcase_144 WA -
testcase_145 WA -
testcase_146 WA -
testcase_147 WA -
testcase_148 WA -
testcase_149 WA -
testcase_150 WA -
testcase_151 WA -
testcase_152 AC 3 ms
5,084 KB
testcase_153 AC 4 ms
6,136 KB
testcase_154 AC 3 ms
4,352 KB
testcase_155 AC 43 ms
8,632 KB
testcase_156 AC 13 ms
5,064 KB
testcase_157 AC 42 ms
8,520 KB
testcase_158 AC 63 ms
10,416 KB
testcase_159 AC 8 ms
4,648 KB
testcase_160 AC 3 ms
4,348 KB
testcase_161 AC 50 ms
9,360 KB
testcase_162 AC 4 ms
5,616 KB
testcase_163 AC 3 ms
4,552 KB
testcase_164 WA -
testcase_165 WA -
testcase_166 WA -
testcase_167 WA -
testcase_168 AC 18 ms
5,552 KB
testcase_169 AC 20 ms
5,760 KB
testcase_170 AC 16 ms
5,132 KB
testcase_171 AC 29 ms
6,720 KB
testcase_172 WA -
testcase_173 WA -
testcase_174 AC 55 ms
9,300 KB
testcase_175 AC 69 ms
11,040 KB
testcase_176 AC 41 ms
8,304 KB
testcase_177 AC 7 ms
4,352 KB
testcase_178 AC 45 ms
8,584 KB
testcase_179 AC 49 ms
8,932 KB
testcase_180 AC 3 ms
5,612 KB
testcase_181 AC 2 ms
4,348 KB
testcase_182 AC 2 ms
4,352 KB
testcase_183 AC 3 ms
4,820 KB
testcase_184 AC 3 ms
4,356 KB
testcase_185 AC 4 ms
5,080 KB
testcase_186 AC 3 ms
5,612 KB
testcase_187 AC 3 ms
4,812 KB
testcase_188 AC 1 ms
4,348 KB
testcase_189 AC 1 ms
4,348 KB
testcase_190 AC 1 ms
4,352 KB
testcase_191 AC 2 ms
4,348 KB
testcase_192 AC 2 ms
4,352 KB
testcase_193 AC 1 ms
4,352 KB
testcase_194 AC 1 ms
4,352 KB
testcase_195 AC 2 ms
4,348 KB
testcase_196 WA -
testcase_197 WA -
testcase_198 WA -
testcase_199 WA -
testcase_200 AC 9 ms
5,360 KB
testcase_201 AC 7 ms
4,348 KB
testcase_202 WA -
testcase_203 WA -
testcase_204 WA -
testcase_205 WA -
testcase_206 AC 5 ms
5,944 KB
testcase_207 AC 14 ms
5,212 KB
testcase_208 WA -
testcase_209 WA -
testcase_210 WA -
testcase_211 WA -
testcase_212 AC 3 ms
4,352 KB
testcase_213 AC 9 ms
4,704 KB
testcase_214 WA -
testcase_215 WA -
testcase_216 WA -
testcase_217 WA -
testcase_218 AC 9 ms
5,888 KB
testcase_219 AC 3 ms
4,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long w, h;
  cin >> w >> h;
  int n;
  cin >> n;
  vector<long long> x(n), y(n), a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    --x[i], --y[i];
    a[i] = x[i] - y[i];
    b[i] = x[i] + y[i];
    if ((a[i] - a[0]) & 1) {
      cout << "0\n";
      return 0;
    }
  }
  if (n == 2) {
    if (x[0] > x[1]) {
      swap(x[0], x[1]);
      swap(y[0], y[1]);
    }
    if (y[0] > y[1]) {
      y[0] = h - y[0] - 1;
      y[1] = h - y[1] - 1;
    }
    long long res = 0;
    if (x[0] - y[0] == x[1] - y[1]) {
      res += x[1] - x[0] - 1;
      res += (w - x[1]) * (y[0] + 1);
      res += (x[0] + 1) * (h - y[1]);
    } else {
      if (x[1] - x[0] < y[1] - y[0]) {
        swap(w, h);
        swap(x[0], y[0]);
        swap(x[1], y[1]);
      }
      res += y[1] - y[0] - 1;
      res += y[0] + 1;
      res += h - y[1];
    }
    cout << res << '\n';
    return 0;
  }
  set<long long> sa(begin(a), end(a));
  set<long long> sb(begin(b), end(b));
  long long min_x = *min_element(begin(x), end(x));
  long long max_x = *max_element(begin(x), end(x));
  long long min_y = *min_element(begin(y), end(y));
  long long max_y = *max_element(begin(y), end(y));
  long long min_a = *begin(sa), max_a = *rbegin(sa);
  long long min_b = *begin(sb), max_b = *rbegin(sb);
  long long res = 0;
  if (sa.size() == 1 or sb.size() == 1) {
    res += (w - max_x) * (min_y + 1);
    res += (min_x + 1) * (h - max_y);
  } else if (sa.size() == 2 or sb.size() == 2) {
    long long da = max_a - min_a;
    assert(~da & 1);
    da /= 2;
    long long db = max_b - min_b;
    assert(~db & 1);
    db /= 2;
    if (sa.size() == 2) {
      res += max(db - da + 1, 0LL);
    } else {
      res += max(da - db + 1, 0LL);
    }
  } else {
    for (int i = 0; i < n; ++i) {
      if (a[i] != min_a and a[i] != max_a and
          b[i] != min_b and b[i] != max_b) {
        cout << "0\n";
        return 0;
      }
    }
    res = 1;
  }
  cout << res << '\n';
}
0