結果

問題 No.960 マンハッタン距離3
ユーザー chocoruskchocorusk
提出日時 2019-12-23 01:02:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,917 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 120,544 KB
実行使用メモリ 6,664 KB
最終ジャッジ日時 2023-10-12 23:51:15
合計ジャッジ時間 12,321 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,392 KB
testcase_01 AC 2 ms
5,388 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,480 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 2 ms
5,392 KB
testcase_17 AC 2 ms
5,396 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
5,528 KB
testcase_20 AC 2 ms
5,444 KB
testcase_21 AC 2 ms
5,708 KB
testcase_22 AC 2 ms
5,500 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 2 ms
5,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 2 ms
4,352 KB
testcase_38 WA -
testcase_39 AC 2 ms
4,352 KB
testcase_40 AC 2 ms
4,352 KB
testcase_41 AC 2 ms
4,352 KB
testcase_42 AC 2 ms
5,400 KB
testcase_43 AC 2 ms
5,392 KB
testcase_44 AC 2 ms
4,348 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 2 ms
4,352 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 2 ms
5,460 KB
testcase_51 AC 2 ms
4,352 KB
testcase_52 AC 2 ms
5,388 KB
testcase_53 AC 2 ms
5,592 KB
testcase_54 AC 1 ms
4,352 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,352 KB
testcase_57 AC 2 ms
4,352 KB
testcase_58 AC 2 ms
4,352 KB
testcase_59 AC 2 ms
4,352 KB
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,348 KB
testcase_62 AC 2 ms
5,408 KB
testcase_63 AC 2 ms
4,348 KB
testcase_64 AC 2 ms
4,352 KB
testcase_65 AC 2 ms
4,352 KB
testcase_66 AC 2 ms
4,352 KB
testcase_67 AC 2 ms
5,380 KB
testcase_68 AC 1 ms
4,352 KB
testcase_69 AC 2 ms
4,348 KB
testcase_70 AC 2 ms
4,352 KB
testcase_71 AC 2 ms
4,352 KB
testcase_72 AC 2 ms
5,484 KB
testcase_73 AC 2 ms
5,460 KB
testcase_74 AC 1 ms
4,480 KB
testcase_75 AC 2 ms
4,352 KB
testcase_76 AC 2 ms
5,384 KB
testcase_77 AC 2 ms
4,352 KB
testcase_78 AC 2 ms
4,348 KB
testcase_79 AC 2 ms
4,352 KB
testcase_80 WA -
testcase_81 WA -
testcase_82 AC 2 ms
4,352 KB
testcase_83 AC 1 ms
4,348 KB
testcase_84 AC 2 ms
5,380 KB
testcase_85 AC 2 ms
5,380 KB
testcase_86 AC 2 ms
4,352 KB
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 2 ms
5,476 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
5,636 KB
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 WA -
testcase_104 AC 2 ms
4,348 KB
testcase_105 AC 2 ms
5,448 KB
testcase_106 WA -
testcase_107 WA -
testcase_108 WA -
testcase_109 WA -
testcase_110 AC 2 ms
4,352 KB
testcase_111 AC 1 ms
4,352 KB
testcase_112 WA -
testcase_113 WA -
testcase_114 WA -
testcase_115 WA -
testcase_116 WA -
testcase_117 WA -
testcase_118 AC 2 ms
4,348 KB
testcase_119 AC 2 ms
4,348 KB
testcase_120 WA -
testcase_121 AC 2 ms
5,484 KB
testcase_122 AC 2 ms
4,352 KB
testcase_123 WA -
testcase_124 AC 2 ms
4,348 KB
testcase_125 AC 2 ms
4,352 KB
testcase_126 AC 2 ms
4,356 KB
testcase_127 AC 1 ms
4,352 KB
testcase_128 AC 27 ms
4,356 KB
testcase_129 AC 71 ms
6,196 KB
testcase_130 AC 50 ms
6,084 KB
testcase_131 AC 87 ms
6,584 KB
testcase_132 WA -
testcase_133 WA -
testcase_134 AC 21 ms
5,684 KB
testcase_135 WA -
testcase_136 WA -
testcase_137 AC 41 ms
4,944 KB
testcase_138 WA -
testcase_139 WA -
testcase_140 AC 83 ms
6,584 KB
testcase_141 WA -
testcase_142 WA -
testcase_143 AC 52 ms
5,488 KB
testcase_144 WA -
testcase_145 WA -
testcase_146 WA -
testcase_147 WA -
testcase_148 AC 30 ms
5,808 KB
testcase_149 AC 47 ms
5,872 KB
testcase_150 AC 68 ms
5,800 KB
testcase_151 AC 5 ms
4,348 KB
testcase_152 AC 58 ms
5,576 KB
testcase_153 AC 86 ms
6,540 KB
testcase_154 AC 4 ms
4,348 KB
testcase_155 AC 60 ms
5,536 KB
testcase_156 AC 21 ms
4,348 KB
testcase_157 AC 59 ms
5,908 KB
testcase_158 AC 80 ms
6,352 KB
testcase_159 AC 12 ms
4,348 KB
testcase_160 AC 5 ms
5,448 KB
testcase_161 AC 69 ms
5,964 KB
testcase_162 AC 74 ms
6,088 KB
testcase_163 AC 42 ms
5,856 KB
testcase_164 AC 79 ms
6,356 KB
testcase_165 AC 62 ms
6,232 KB
testcase_166 AC 12 ms
4,352 KB
testcase_167 AC 40 ms
5,004 KB
testcase_168 AC 27 ms
4,608 KB
testcase_169 AC 30 ms
4,732 KB
testcase_170 AC 24 ms
4,352 KB
testcase_171 AC 41 ms
5,112 KB
testcase_172 AC 31 ms
4,516 KB
testcase_173 AC 7 ms
5,664 KB
testcase_174 AC 70 ms
6,252 KB
testcase_175 AC 86 ms
6,460 KB
testcase_176 AC 58 ms
6,144 KB
testcase_177 AC 9 ms
4,352 KB
testcase_178 AC 60 ms
6,060 KB
testcase_179 AC 65 ms
6,092 KB
testcase_180 AC 81 ms
6,424 KB
testcase_181 AC 18 ms
4,352 KB
testcase_182 AC 36 ms
5,756 KB
testcase_183 AC 49 ms
6,216 KB
testcase_184 AC 37 ms
5,740 KB
testcase_185 AC 58 ms
5,908 KB
testcase_186 AC 72 ms
6,276 KB
testcase_187 AC 54 ms
5,240 KB
testcase_188 AC 1 ms
4,352 KB
testcase_189 AC 1 ms
4,348 KB
testcase_190 WA -
testcase_191 WA -
testcase_192 WA -
testcase_193 AC 1 ms
4,348 KB
testcase_194 AC 2 ms
5,380 KB
testcase_195 AC 2 ms
4,352 KB
testcase_196 WA -
testcase_197 WA -
testcase_198 WA -
testcase_199 WA -
testcase_200 AC 67 ms
6,128 KB
testcase_201 AC 39 ms
6,044 KB
testcase_202 WA -
testcase_203 WA -
testcase_204 WA -
testcase_205 WA -
testcase_206 AC 75 ms
6,324 KB
testcase_207 AC 56 ms
5,440 KB
testcase_208 WA -
testcase_209 WA -
testcase_210 WA -
testcase_211 WA -
testcase_212 AC 19 ms
5,528 KB
testcase_213 AC 40 ms
4,828 KB
testcase_214 WA -
testcase_215 WA -
testcase_216 WA -
testcase_217 WA -
testcase_218 AC 80 ms
6,664 KB
testcase_219 AC 41 ms
5,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll w, h;
	cin>>w>>h;
	int n;
	cin>>n;
	ll x[100010], y[100010];
	ll x1[100010], y1[100010];
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i];
		x1[i]=x[i]+y[i], y1[i]=x[i]-y[i];
	}
	sort(x1, x1+n);
	sort(y1, y1+n);
	ll d=max(x1[n-1]-x1[0], y1[n-1]-y1[0]);
	set<P> st;
	ll px[2], py[2];
	if(d%2!=0){
		cout<<0<<endl;
		return 0;
	}
	if(x1[0]==x1[n-1]){
		sort(x, x+n);
		sort(y, y+n);
		cout<<x[0]*y[0]+(w-x[n-1]+1)*(h-y[n-1]+1)<<endl;
		return 0;
	}
	if(y1[0]==y1[n-1]){
		sort(x, x+n);
		sort(y, y+n);
		cout<<(w-x[n-1]+1)*y[0]+x[0]*(h-y[n-1]+1)<<endl;
		return 0;
	}
	{
		px[0]=x1[n-1]-d/2, px[1]=x1[0]+d/2;
		py[0]=y1[n-1]-d/2, py[1]=y1[0]+d/2;
		for(int i=0; i<2; i++){
			for(int j=0; j<2; j++){
				ll x0=(px[i]+py[j])/2, y0=(px[i]-py[j])/2;
				if(x0*2!=px[i]+py[j]) continue;
				bool dame=0;
				for(int k=0; k<n; k++){
					if(abs(x[k]-x0)+abs(y[k]-y0)!=abs(x[0]-x0)+abs(y[0]-y0)){
						dame=1;
						break;
					}
				}
				if(!dame){
					st.insert({x0, y0});
				}
			}
		}
	}
	const ll INF=1e18;
	for(auto p:st){
		ll x0=p.first, y0=p.second;
		y0+=INF;
		bool dame1=0, dame2=0;
		for(int k=0; k<n; k++){
			if(abs(x[k]-x0)+abs(y[k]-y0)!=abs(x[0]-x0)+abs(y[0]-y0)){
				dame1=1;
				break;
			}
		}
		y0-=2*INF;
		for(int k=0; k<n; k++){
			if(abs(x[k]-x0)+abs(y[k]-y0)!=abs(x[0]-x0)+abs(y[0]-y0)){
				dame2=1;
				break;
			}
		}
		y0+=INF;
		if(!dame1 && !dame2){
			if(1<=x0 && x0<=w) cout<<h<<endl;
			else cout<<0<<endl;
			return 0;
		}else if(!dame1){
			if(1<=x0 && x0<=w) cout<<max(0ll, h-y0+1)<<endl;
			else cout<<0<<endl;
		}else if(!dame2){
			if(1<=x0 && x0<=w) cout<<max(0ll, y0)<<endl;
			else cout<<0<<endl;
		}
		x0+=INF;
		dame1=0, dame2=0;
		for(int k=0; k<n; k++){
			if(abs(x[k]-x0)+abs(y[k]-y0)!=abs(x[0]-x0)+abs(y[0]-y0)){
				dame1=1;
				break;
			}
		}
		x0-=2*INF;
		for(int k=0; k<n; k++){
			if(abs(x[k]-x0)+abs(y[k]-y0)!=abs(x[0]-x0)+abs(y[0]-y0)){
				dame2=1;
				break;
			}
		}
		x0+=INF;
		if(!dame1 && !dame2){
			if(1<=y0 && y0<=h) cout<<w<<endl;
			else cout<<0<<endl;
			return 0;
		}else if(!dame1){
			if(1<=y0 && y0<=h) cout<<max(0ll, w-x0+1)<<endl;
			else cout<<0<<endl;
		}else if(!dame2){
			if(1<=y0 && y0<=h) cout<<max(0ll, x0)<<endl;
			else cout<<0<<endl;
		}
	}
	int ans=0;
	for(auto p:st){
		if(1<=p.first && p.first<=w && 1<=p.second && p.second<=h){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0