結果

問題 No.960 マンハッタン距離3
ユーザー 👑 kmjpkmjp
提出日時 2019-12-23 01:33:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,901 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 169,300 KB
実行使用メモリ 5,064 KB
最終ジャッジ日時 2023-10-13 00:56:56
合計ジャッジ時間 27,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 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 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 1 ms
4,348 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 1 ms
4,352 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 AC 1 ms
4,352 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 1 ms
4,352 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 AC 1 ms
4,348 KB
testcase_73 AC 2 ms
4,352 KB
testcase_74 AC 1 ms
4,352 KB
testcase_75 AC 2 ms
4,348 KB
testcase_76 AC 2 ms
4,352 KB
testcase_77 AC 2 ms
4,352 KB
testcase_78 AC 1 ms
4,348 KB
testcase_79 AC 1 ms
4,348 KB
testcase_80 AC 2 ms
4,348 KB
testcase_81 WA -
testcase_82 AC 2 ms
4,352 KB
testcase_83 AC 1 ms
4,348 KB
testcase_84 AC 1 ms
4,352 KB
testcase_85 AC 2 ms
4,352 KB
testcase_86 AC 2 ms
4,348 KB
testcase_87 WA -
testcase_88 RE -
testcase_89 RE -
testcase_90 RE -
testcase_91 RE -
testcase_92 AC 2 ms
4,352 KB
testcase_93 AC 1 ms
4,348 KB
testcase_94 RE -
testcase_95 RE -
testcase_96 RE -
testcase_97 RE -
testcase_98 AC 2 ms
4,348 KB
testcase_99 AC 2 ms
4,348 KB
testcase_100 RE -
testcase_101 RE -
testcase_102 RE -
testcase_103 WA -
testcase_104 AC 1 ms
4,352 KB
testcase_105 AC 1 ms
4,348 KB
testcase_106 RE -
testcase_107 RE -
testcase_108 RE -
testcase_109 RE -
testcase_110 AC 2 ms
4,348 KB
testcase_111 AC 2 ms
4,348 KB
testcase_112 WA -
testcase_113 WA -
testcase_114 WA -
testcase_115 WA -
testcase_116 WA -
testcase_117 WA -
testcase_118 AC 1 ms
4,348 KB
testcase_119 AC 2 ms
4,348 KB
testcase_120 WA -
testcase_121 AC 1 ms
4,348 KB
testcase_122 AC 1 ms
4,348 KB
testcase_123 WA -
testcase_124 WA -
testcase_125 AC 1 ms
4,348 KB
testcase_126 AC 2 ms
4,352 KB
testcase_127 AC 2 ms
4,352 KB
testcase_128 RE -
testcase_129 RE -
testcase_130 RE -
testcase_131 RE -
testcase_132 RE -
testcase_133 RE -
testcase_134 AC 7 ms
4,348 KB
testcase_135 RE -
testcase_136 RE -
testcase_137 AC 13 ms
4,348 KB
testcase_138 RE -
testcase_139 RE -
testcase_140 AC 25 ms
4,968 KB
testcase_141 RE -
testcase_142 RE -
testcase_143 AC 16 ms
4,352 KB
testcase_144 RE -
testcase_145 RE -
testcase_146 RE -
testcase_147 RE -
testcase_148 RE -
testcase_149 RE -
testcase_150 RE -
testcase_151 RE -
testcase_152 AC 18 ms
4,496 KB
testcase_153 AC 26 ms
4,988 KB
testcase_154 RE -
testcase_155 RE -
testcase_156 RE -
testcase_157 RE -
testcase_158 RE -
testcase_159 RE -
testcase_160 RE -
testcase_161 RE -
testcase_162 AC 23 ms
4,800 KB
testcase_163 AC 14 ms
4,352 KB
testcase_164 RE -
testcase_165 RE -
testcase_166 RE -
testcase_167 RE -
testcase_168 RE -
testcase_169 RE -
testcase_170 RE -
testcase_171 RE -
testcase_172 RE -
testcase_173 RE -
testcase_174 RE -
testcase_175 RE -
testcase_176 RE -
testcase_177 RE -
testcase_178 RE -
testcase_179 RE -
testcase_180 AC 23 ms
4,796 KB
testcase_181 AC 6 ms
4,348 KB
testcase_182 AC 11 ms
4,348 KB
testcase_183 AC 14 ms
4,524 KB
testcase_184 AC 11 ms
4,352 KB
testcase_185 AC 17 ms
4,392 KB
testcase_186 AC 21 ms
4,676 KB
testcase_187 AC 16 ms
4,368 KB
testcase_188 AC 2 ms
4,352 KB
testcase_189 AC 1 ms
4,348 KB
testcase_190 WA -
testcase_191 WA -
testcase_192 WA -
testcase_193 AC 2 ms
4,352 KB
testcase_194 AC 1 ms
4,348 KB
testcase_195 AC 2 ms
4,348 KB
testcase_196 RE -
testcase_197 RE -
testcase_198 RE -
testcase_199 RE -
testcase_200 AC 21 ms
4,716 KB
testcase_201 AC 12 ms
4,348 KB
testcase_202 RE -
testcase_203 RE -
testcase_204 RE -
testcase_205 RE -
testcase_206 AC 23 ms
4,848 KB
testcase_207 AC 17 ms
4,468 KB
testcase_208 RE -
testcase_209 RE -
testcase_210 RE -
testcase_211 RE -
testcase_212 AC 7 ms
4,348 KB
testcase_213 AC 13 ms
4,400 KB
testcase_214 RE -
testcase_215 RE -
testcase_216 RE -
testcase_217 RE -
testcase_218 AC 25 ms
4,836 KB
testcase_219 AC 13 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll H,W;
int N;
ll X[101010],Y[101010];


struct area{
	int type;
	int X[2],Y[2];
} ;

void add_line(vector<area>& A,int X0,int Y0,int X1,int Y1) {
	if(X0>X1) return;
	if(X0==X1 && Y0>Y1) return;
	
	area a;
	
	if(Y0==Y1) a.type=0;
	else if(X0==X1) a.type=1;
	else if(Y0<Y1) a.type=2;
	else a.type=3;
	
	a.X[0]=X0;
	a.X[1]=X1;
	a.Y[0]=Y0;
	a.Y[1]=Y1;
	A.push_back(a);
}

void add_area(vector<area>& A,int X0,int Y0,int X1,int Y1) {
	if(X0>X1) return;
	if(Y0>Y1) return;
	
	area a;
	a.type=4;
	
	a.X[0]=X0;
	a.X[1]=X1;
	a.Y[0]=Y0;
	a.Y[1]=Y1;
	A.push_back(a);
	
}

ll get_area(area a) {
	ll ret=0;
	if(a.type==4) {
		return (ll)(a.X[1]-a.X[0]+1)*(a.Y[1]-a.Y[0]+1);
	}
	else {
		return max(abs(a.X[0]-a.X[1]),abs(a.Y[0]-a.Y[1])+1);
	}
}

vector<area> hoge(int X0,int Y0,int X1,int Y1) {
	vector<area> V;
	if(X0>X1) swap(X0,X1),swap(Y0,Y1);
	if(X0==X1) {
		add_line(V,0,(Y[0]+Y[1])/2,W-1,(Y[0]+Y[1])/2);
	}
	else if(Y0==Y1) {
		add_line(V,(X[0]+X[1])/2,0,(X[0]+X[1])/2,H-1);
	}
	else if(abs(X[0]-X[1])<abs(Y[0]-Y[1])) {
		int y0,y1;
		if(Y[0]<Y[1]) {
			y0=(Y[0]+Y[1]+(X[1]-X[0]))/2;
			y1=(Y[0]+Y[1]-(X[1]-X[0]))/2;
		}
		else {
			y0=(Y[0]+Y[1]-(X[1]-X[0]))/2;
			y1=(Y[0]+Y[1]+(X[1]-X[0]))/2;
		}
		add_line(V,0,y0,X[0]-1,y0);
		add_line(V,X[0],y0,X[1],y1);
		add_line(V,X[1]+1,y1,W-1,y1);
	}
	else if(abs(X[0]-X[1])>abs(Y[0]-Y[1])) {
		int x0,x1;
		if(X[0]<X[1]) {
			x0=(X[0]+X[1]+(Y[1]-Y[0]))/2;
			x1=(X[0]+X[1]-(Y[1]-Y[0]))/2;
		}
		else {
			x0=(X[0]+X[1]-(Y[1]-Y[0]))/2;
			x1=(X[0]+X[1]+(Y[1]-Y[0]))/2;
		}
		add_line(V,x0,0,x0,Y[0]-1);
		add_line(V,x0,Y[0],x1,Y[1]);
		add_line(V,x1,Y[1]+1,x1,H-1);
	}
	else {
		if(Y[0]<Y[1]) {
			add_area(V,0,Y[1],X[0],H-1);
			add_area(V,X[1],0,W-1,Y[0]);
			add_line(V,X[0]+1,Y[1]-1,X[1]-1,Y[0]+1);
		}
		else {
			add_area(V,0,0,X[0],Y[1]);
			add_area(V,X[1],Y[0],W-1,H-1);
			add_line(V,X[0]+1,Y[0]+1,X[1]-1,Y[1]-1);
		}
	}
	return V;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>W>>H;
	cin>>N;
	int C[2]={};
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		X[i]--;
		Y[i]--;
		C[(X[i]+Y[i])%2]++;
	}
	
	if(C[0]>0 && C[0]<N) return _P("0\n");
	
	if(N==2) {
		auto V=hoge(X[0],Y[0],X[1],Y[1]);
		ll ret=0;
		FORR(a,V) ret+=get_area(a);
		cout<<ret<<endl;
	}
	else {
		assert(0);
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0