結果
| 問題 |
No.960 マンハッタン距離3
|
| コンテスト | |
| ユーザー |
emthrm
|
| 提出日時 | 2019-12-28 20:57:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,501 bytes |
| コンパイル時間 | 1,579 ms |
| コンパイル使用メモリ | 120,904 KB |
| 最終ジャッジ日時 | 2025-01-08 15:13:38 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 156 WA * 60 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
// dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
struct IOSetup {
IOSetup() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(20);
cerr << fixed << setprecision(10);
}
} iosetup;
/*-------------------------------------------------*/
int main() {
long long w, h; int n; cin >> w >> h >> n;
vector<long long> x(n), y(n);
REP(i, n) cin >> x[i] >> y[i];
FOR(i, 1, n) {
if ((x[0] + y[0]) % 2 != (x[i] + y[i]) % 2) {
cout << "0\n";
return 0;
}
}
long long ans = 0;
REP(rot, 4) {
REP(flip, 2) {
long long mn_x = LINF, mx_x = -LINF, mn_y = LINF, mx_y = -LINF, mn_plus = LINF, mx_plus = -LINF, mn_minus = LINF, mx_minus = -LINF;
REP(i, n) {
mn_x = min(mn_x, x[i]);
mx_x = max(mx_x, x[i]);
mn_y = min(mn_y, y[i]);
mx_y = max(mx_y, y[i]);
mn_plus = min(mn_plus, x[i] + y[i]);
mx_plus = max(mx_plus, x[i] + y[i]);
mn_minus = min(mn_minus, x[i] - y[i]);
mx_minus = max(mx_minus, x[i] - y[i]);
}
if (n == 2) {
if (mn_plus == mx_plus) ans = max(ans, mn_x * mn_y + (w - mx_x + 1) * (h - mx_y + 1) + mx_x - mn_x - 1);
if (mx_x - mn_x < mx_y - mn_y) ans = max(ans, w);
} else {
if (mn_plus == mx_plus) ans = max(ans, mn_x * mn_y + (w - mx_x + 1) * (h - mx_y + 1));
bool flag = true;
if (mx_plus - mn_plus >= mx_minus - mn_minus) {
REP(i, n) flag &= x[i] + y[i] == mx_plus || x[i] + y[i] == mn_plus;
if (flag) ans = max(ans, ((mx_plus - mx_minus) - (mx_minus - mn_minus)) / 2 + 1);
}
flag = true;
int cnt = 0;
REP(i, n) {
if (x[i] + y[i] != mx_plus) {
++cnt;
flag &= x[i] - y[i] == mx_minus;
}
}
if (flag && cnt == 1) {
long long tmp = LINF;
REP(i, n) if (x[i] + y[i] == mx_plus) tmp = min(tmp, x[i]);
ans = max(ans, tmp);
}
if (mx_plus - mn_plus >= mx_minus - mn_minus) {
flag = true;
REP(i, n) flag &= x[i] + y[i] == mx_plus || x[i] + y[i] == mn_plus || x[i] - y[i] == mx_minus;
if (flag) ans = max(ans, 1LL);
}
if (mx_plus - mn_plus == mx_minus - mn_minus) {
flag = true;
REP(i, n) flag &= x[i] + y[i] == mx_plus || x[i] + y[i] == mn_plus || x[i] - y[i] == mx_minus || x[i] - y[i] == mn_minus;
if (flag) ans = max(ans, 1LL);
}
}
REP(i, n) y[i] = h - y[i] + 1;
}
REP(i, n) {
swap(x[i], y[i]);
(y[i] *= -1) += h + 1;
swap(h, w);
}
}
cout << ans << '\n';
return 0;
}
emthrm