結果
| 問題 |
No.3292 World Map Distance
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2025-10-03 23:07:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 620 ms / 3,000 ms |
| コード長 | 3,803 bytes |
| コンパイル時間 | 4,283 ms |
| コンパイル使用メモリ | 264,032 KB |
| 実行使用メモリ | 93,800 KB |
| 最終ジャッジ日時 | 2025-10-03 23:07:34 |
| 合計ジャッジ時間 | 14,961 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
/**
author: shobonvip
created: 2025.10.03 22:26:44
**/
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
#define all(v) v.begin(), v.end()
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, h, w;
cin >> n >> h >> w;
vector<ll> x(n), y(n);
rep(i,0,n) {
cin >> x[i] >> y[i];
x[i]--; y[i]--;
}
vector<tuple<ll,ll,ll>> event_x, event_y;
rep(i,0,n) {
ll rx = min(abs((h + 1) / 2), h - abs((h + 1) / 2));
ll ry = min(abs((w + 1) / 2), w - abs((w + 1) / 2));
event_x.push_back(make_tuple(x[i], - x[i], + 1));
event_y.push_back(make_tuple(y[i], - y[i], + 1));
event_x.push_back(make_tuple(x[i] + h / 2, 0, 0));
event_y.push_back(make_tuple(y[i] + w / 2, 0, 0));
event_x.push_back(make_tuple(x[i] + (h + 1) / 2, x[i], - 1));
event_y.push_back(make_tuple(y[i] + (w + 1) / 2, y[i], - 1));
event_x.push_back(make_tuple(x[i] + (h + 1) / 2, rx + x[i] + (h + 1) / 2, - 1));
event_y.push_back(make_tuple(y[i] + (w + 1) / 2, ry + y[i] + (w + 1) / 2, - 1));
event_x.push_back(make_tuple(x[i] + h, - rx - x[i] - (h + 1) / 2 , + 1));
event_y.push_back(make_tuple(y[i] + w, - ry - y[i] - (w + 1) / 2 , + 1));
event_x.push_back(make_tuple(x[i] + h, - x[i] - h, + 1));
event_y.push_back(make_tuple(y[i] + w, - y[i] - w, + 1));
event_x.push_back(make_tuple(x[i] + h + h / 2, 0, 0));
event_y.push_back(make_tuple(y[i] + w + w / 2, 0, 0));
event_x.push_back(make_tuple(x[i] + h + (h + 1) / 2, x[i] + h, - 1));
event_y.push_back(make_tuple(y[i] + w + (w + 1) / 2, y[i] + w, - 1));
event_x.push_back(make_tuple(x[i] + h + (h + 1) / 2, rx + x[i] + h + (h + 1) / 2, - 1));
event_y.push_back(make_tuple(y[i] + w + (w + 1) / 2, ry + y[i] + w + (w + 1) / 2, - 1));
}
sort(all(event_x));
sort(all(event_y));
ll ans = 0;
{
ll now = -1;
ll lin = 0;
ll con = 0;
int i = 0;
ll ansx = -1e18;
while (i < (int)event_x.size()) {
ll time = get<0>(event_x[i]);
ll dcon = get<1>(event_x[i]);
ll dlin = get<2>(event_x[i]);
con += dcon;
lin += dlin;
i = i + 1;
now = time;
if (i < (int)event_x.size() && now == get<0>(event_x[i])) {
continue;
}
if (now >= h && now < 2 * h) {
chmax(ansx, lin * now + con);
//cout << now << ' ' << lin * now + con << endl;
}
}
ans += ansx;
}
{
ll now = -1;
ll lin = 0;
ll con = 0;
int i = 0;
ll ansy = -1e18;
while (i < (int)event_y.size()) {
ll time = get<0>(event_y[i]);
ll dcon = get<1>(event_y[i]);
ll dlin = get<2>(event_y[i]);
con += dcon;
lin += dlin;
i = i + 1;
now = time;
if (i < (int)event_y.size() && now == get<0>(event_y[i])) {
continue;
}
if (now >= w && now < 2 * w) {
chmax(ansy, lin * now + con);
//cout << now << ' ' << lin * now + con << endl;
}
}
ans += ansy;
}
cout << ans << endl;
}
shobonvip