結果

問題 No.960 マンハッタン距離3
ユーザー kotatsugamekotatsugame
提出日時 2019-12-21 23:23:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,187 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 76,432 KB
実行使用メモリ 5,700 KB
最終ジャッジ日時 2023-10-11 14:32:10
合計ジャッジ時間 11,306 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,444 KB
testcase_01 AC 2 ms
5,368 KB
testcase_02 AC 2 ms
5,364 KB
testcase_03 AC 2 ms
5,352 KB
testcase_04 AC 2 ms
5,372 KB
testcase_05 AC 2 ms
5,432 KB
testcase_06 AC 2 ms
5,356 KB
testcase_07 AC 3 ms
5,388 KB
testcase_08 AC 2 ms
5,364 KB
testcase_09 AC 2 ms
5,380 KB
testcase_10 AC 2 ms
5,556 KB
testcase_11 AC 2 ms
5,412 KB
testcase_12 AC 2 ms
5,360 KB
testcase_13 AC 2 ms
5,528 KB
testcase_14 AC 2 ms
5,552 KB
testcase_15 AC 2 ms
5,368 KB
testcase_16 AC 2 ms
5,348 KB
testcase_17 AC 2 ms
5,356 KB
testcase_18 AC 2 ms
5,500 KB
testcase_19 AC 2 ms
5,428 KB
testcase_20 AC 2 ms
5,384 KB
testcase_21 AC 2 ms
5,408 KB
testcase_22 AC 2 ms
5,352 KB
testcase_23 AC 2 ms
5,408 KB
testcase_24 AC 2 ms
5,348 KB
testcase_25 AC 2 ms
5,352 KB
testcase_26 AC 2 ms
5,380 KB
testcase_27 AC 2 ms
5,352 KB
testcase_28 AC 2 ms
5,352 KB
testcase_29 AC 2 ms
5,432 KB
testcase_30 AC 2 ms
5,356 KB
testcase_31 AC 2 ms
5,688 KB
testcase_32 AC 2 ms
5,632 KB
testcase_33 AC 2 ms
5,564 KB
testcase_34 AC 2 ms
5,428 KB
testcase_35 AC 2 ms
5,348 KB
testcase_36 AC 2 ms
5,408 KB
testcase_37 AC 2 ms
5,400 KB
testcase_38 AC 2 ms
5,428 KB
testcase_39 AC 2 ms
5,508 KB
testcase_40 AC 2 ms
5,464 KB
testcase_41 AC 3 ms
5,364 KB
testcase_42 AC 2 ms
5,408 KB
testcase_43 AC 2 ms
5,360 KB
testcase_44 AC 2 ms
5,408 KB
testcase_45 AC 2 ms
5,360 KB
testcase_46 AC 2 ms
5,404 KB
testcase_47 AC 2 ms
5,552 KB
testcase_48 AC 2 ms
5,412 KB
testcase_49 AC 2 ms
5,644 KB
testcase_50 AC 2 ms
5,360 KB
testcase_51 AC 2 ms
5,432 KB
testcase_52 AC 2 ms
5,672 KB
testcase_53 AC 2 ms
5,564 KB
testcase_54 AC 2 ms
5,368 KB
testcase_55 AC 3 ms
5,436 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,412 KB
testcase_58 AC 2 ms
5,368 KB
testcase_59 AC 2 ms
5,492 KB
testcase_60 AC 2 ms
5,360 KB
testcase_61 AC 2 ms
5,436 KB
testcase_62 AC 2 ms
5,464 KB
testcase_63 AC 2 ms
5,412 KB
testcase_64 AC 2 ms
5,372 KB
testcase_65 AC 2 ms
5,592 KB
testcase_66 AC 2 ms
5,400 KB
testcase_67 AC 2 ms
5,400 KB
testcase_68 AC 2 ms
5,552 KB
testcase_69 AC 2 ms
5,484 KB
testcase_70 AC 2 ms
5,568 KB
testcase_71 AC 2 ms
5,384 KB
testcase_72 AC 3 ms
5,400 KB
testcase_73 AC 2 ms
5,660 KB
testcase_74 AC 2 ms
5,640 KB
testcase_75 AC 2 ms
5,368 KB
testcase_76 AC 2 ms
5,496 KB
testcase_77 AC 2 ms
5,492 KB
testcase_78 AC 2 ms
5,356 KB
testcase_79 AC 2 ms
5,372 KB
testcase_80 AC 2 ms
5,352 KB
testcase_81 AC 2 ms
5,376 KB
testcase_82 AC 2 ms
5,496 KB
testcase_83 AC 2 ms
5,432 KB
testcase_84 AC 2 ms
5,408 KB
testcase_85 AC 2 ms
5,432 KB
testcase_86 AC 2 ms
5,468 KB
testcase_87 AC 2 ms
5,496 KB
testcase_88 AC 2 ms
5,556 KB
testcase_89 AC 2 ms
5,348 KB
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 2 ms
5,440 KB
testcase_93 AC 2 ms
5,368 KB
testcase_94 AC 2 ms
5,364 KB
testcase_95 AC 2 ms
5,432 KB
testcase_96 WA -
testcase_97 WA -
testcase_98 AC 2 ms
5,360 KB
testcase_99 AC 2 ms
5,432 KB
testcase_100 AC 2 ms
5,640 KB
testcase_101 AC 2 ms
5,412 KB
testcase_102 WA -
testcase_103 AC 2 ms
5,416 KB
testcase_104 AC 2 ms
5,352 KB
testcase_105 AC 2 ms
5,404 KB
testcase_106 AC 2 ms
5,452 KB
testcase_107 AC 2 ms
5,436 KB
testcase_108 WA -
testcase_109 WA -
testcase_110 AC 2 ms
5,372 KB
testcase_111 AC 2 ms
5,432 KB
testcase_112 AC 2 ms
5,424 KB
testcase_113 AC 2 ms
5,428 KB
testcase_114 AC 2 ms
5,424 KB
testcase_115 AC 2 ms
5,456 KB
testcase_116 AC 2 ms
5,500 KB
testcase_117 AC 2 ms
5,456 KB
testcase_118 AC 2 ms
5,564 KB
testcase_119 AC 2 ms
5,360 KB
testcase_120 AC 2 ms
5,428 KB
testcase_121 AC 2 ms
5,472 KB
testcase_122 AC 2 ms
5,400 KB
testcase_123 AC 2 ms
5,368 KB
testcase_124 AC 2 ms
5,368 KB
testcase_125 AC 2 ms
5,436 KB
testcase_126 AC 2 ms
5,408 KB
testcase_127 AC 2 ms
5,360 KB
testcase_128 AC 21 ms
5,368 KB
testcase_129 AC 54 ms
5,548 KB
testcase_130 AC 39 ms
5,368 KB
testcase_131 AC 65 ms
5,404 KB
testcase_132 AC 66 ms
5,348 KB
testcase_133 AC 3 ms
5,368 KB
testcase_134 AC 18 ms
5,460 KB
testcase_135 AC 23 ms
5,508 KB
testcase_136 AC 24 ms
5,688 KB
testcase_137 AC 34 ms
5,432 KB
testcase_138 AC 48 ms
5,364 KB
testcase_139 AC 57 ms
5,552 KB
testcase_140 AC 71 ms
5,468 KB
testcase_141 AC 74 ms
5,440 KB
testcase_142 AC 32 ms
5,352 KB
testcase_143 AC 44 ms
5,672 KB
testcase_144 AC 60 ms
5,496 KB
testcase_145 AC 6 ms
5,384 KB
testcase_146 AC 16 ms
5,440 KB
testcase_147 AC 50 ms
5,436 KB
testcase_148 AC 28 ms
5,492 KB
testcase_149 AC 44 ms
5,356 KB
testcase_150 AC 63 ms
5,432 KB
testcase_151 AC 5 ms
5,492 KB
testcase_152 AC 49 ms
5,512 KB
testcase_153 AC 74 ms
5,552 KB
testcase_154 AC 4 ms
5,668 KB
testcase_155 AC 56 ms
5,492 KB
testcase_156 AC 20 ms
5,436 KB
testcase_157 AC 55 ms
5,408 KB
testcase_158 AC 71 ms
5,380 KB
testcase_159 AC 12 ms
5,428 KB
testcase_160 AC 5 ms
5,404 KB
testcase_161 AC 65 ms
5,408 KB
testcase_162 AC 63 ms
5,404 KB
testcase_163 AC 36 ms
5,372 KB
testcase_164 AC 76 ms
5,564 KB
testcase_165 AC 59 ms
5,380 KB
testcase_166 AC 12 ms
5,556 KB
testcase_167 AC 38 ms
5,492 KB
testcase_168 AC 26 ms
5,644 KB
testcase_169 AC 28 ms
5,492 KB
testcase_170 AC 23 ms
5,352 KB
testcase_171 AC 39 ms
5,408 KB
testcase_172 AC 29 ms
5,456 KB
testcase_173 AC 7 ms
5,436 KB
testcase_174 AC 62 ms
5,496 KB
testcase_175 AC 81 ms
5,428 KB
testcase_176 AC 54 ms
5,412 KB
testcase_177 AC 8 ms
5,556 KB
testcase_178 AC 54 ms
5,352 KB
testcase_179 AC 59 ms
5,556 KB
testcase_180 AC 64 ms
5,508 KB
testcase_181 AC 15 ms
5,640 KB
testcase_182 AC 29 ms
5,396 KB
testcase_183 AC 39 ms
5,432 KB
testcase_184 AC 31 ms
5,356 KB
testcase_185 AC 47 ms
5,352 KB
testcase_186 AC 58 ms
5,364 KB
testcase_187 AC 44 ms
5,368 KB
testcase_188 AC 2 ms
5,372 KB
testcase_189 AC 2 ms
5,552 KB
testcase_190 AC 2 ms
5,352 KB
testcase_191 AC 2 ms
5,504 KB
testcase_192 AC 2 ms
5,688 KB
testcase_193 AC 2 ms
5,428 KB
testcase_194 AC 2 ms
5,436 KB
testcase_195 AC 2 ms
5,376 KB
testcase_196 AC 46 ms
5,668 KB
testcase_197 AC 14 ms
5,572 KB
testcase_198 WA -
testcase_199 WA -
testcase_200 AC 58 ms
5,408 KB
testcase_201 AC 34 ms
5,408 KB
testcase_202 AC 54 ms
5,628 KB
testcase_203 AC 30 ms
5,456 KB
testcase_204 WA -
testcase_205 WA -
testcase_206 AC 64 ms
5,440 KB
testcase_207 AC 47 ms
5,436 KB
testcase_208 AC 52 ms
5,368 KB
testcase_209 AC 17 ms
5,368 KB
testcase_210 WA -
testcase_211 WA -
testcase_212 AC 16 ms
5,456 KB
testcase_213 AC 34 ms
5,428 KB
testcase_214 AC 73 ms
5,560 KB
testcase_215 AC 61 ms
5,352 KB
testcase_216 WA -
testcase_217 WA -
testcase_218 AC 69 ms
5,472 KB
testcase_219 AC 35 ms
5,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:34:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   34 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<map>
using namespace std;
long W,H;
int N;
long X[1<<17],Y[1<<17];
int check(long x,long y)
{
	if(!(1<=x&&x<=W&&1<=y&&y<=H))return 0;
	int dis=abs(X[0]-x)+abs(Y[0]-y);
	for(int i=1;i<N;i++)
	{
		int now=abs(X[i]-x)+abs(Y[i]-y);
		if(dis!=now)return 0;
	}
	return 1;
}
long XX[1<<17],YY[1<<17];
long ans;
void rotate(long now)
{
	ans=max(ans,now);
	for(int i=0;i<N;i++)
	{
		int x=X[i],y=Y[i];
		X[i]=H-y+1;
		Y[i]=x;
	}
	swap(H,W);
}
main()
{
	cin>>W>>H>>N;
	for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
	for(int i=1;i<N;i++)
	{
		if((X[0]+Y[0])%2!=(X[i]+Y[i])%2)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	long now;
	for(int ccc=0;ccc<4;rotate(now),ccc++)
	{
		now=0;
		long mx=1e18,Mx=-1e18,my=1e18,My=-1e18;
		long mxpy=1e18,Mxpy=-1e18,mxmy=1e18,Mxmy=-1e18;
		for(int i=0;i<N;i++)
		{
			mx=min(mx,X[i]);
			Mx=max(Mx,X[i]);
			my=min(my,Y[i]);
			My=max(My,Y[i]);
			mxpy=min(mxpy,X[i]+Y[i]);
			Mxpy=max(Mxpy,X[i]+Y[i]);
			mxmy=min(mxmy,X[i]-Y[i]);
			Mxmy=max(Mxmy,X[i]-Y[i]);
		}
		if(N==2)
		{
			if(mxpy==Mxpy)
			{
				now=mx*my+(W-Mx+1)*(H-My+1)+(Mx-mx)-1;
			}
			else if(Mx-mx<My-my)
			{
				now=W;
			}
			continue;
		}
		if(mxpy==Mxpy)
		{
			now=mx*my+(W-Mx+1)*(H-My+1);
			continue;
		}
		bool triangle=true;
		for(int i=0;i<N;i++)
		{
			triangle&=X[i]+Y[i]==Mxpy||X[i]-Y[i]==mxmy;
		}
		if(triangle)
		{
			//    /\
			//   /  \
			//  /    \
			// /
			//
			now+=my;
		}
		bool horizontalB=Mxmy-mxmy>=Mxpy-mxpy;
		for(int i=0;i<N;i++)
		{
			horizontalB&=X[i]-Y[i]==Mxmy||X[i]-Y[i]==mxmy;
		}
		if(horizontalB)
		{
			// A
			// \    \
			//  \    \
			//   \    \
			// 
			// B
			//   /   /
			//  /   /
			// /   /
			//
			now+=-(Mxpy-mxpy)/2+(Mxmy-mxmy)/2+1;
			if(triangle)now--;
		}
		if(triangle||horizontalB)continue;
		bool corner=Mxpy-mxpy>=Mxmy-mxmy;
		for(int i=0;i<N;i++)
		{
			corner&=X[i]+Y[i]==Mxpy||X[i]+Y[i]==mxpy||X[i]-Y[i]==Mxmy;
		}
		if(corner)
		{
			now=1;
			continue;
		}
		bool square=Mxpy-mxpy==Mxmy-mxmy;
		for(int i=0;i<N;i++)
		{
			square&=X[i]+Y[i]==Mxpy||X[i]+Y[i]==mxpy||X[i]-Y[i]==Mxmy||X[i]-Y[i]==mxmy;
		}
		if(square)now=1;
	}
	cout<<ans<<endl;
}
0