結果
問題 | No.960 マンハッタン距離3 |
ユーザー | chocorusk |
提出日時 | 2019-12-23 01:52:23 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,273 bytes |
コンパイル時間 | 1,235 ms |
コンパイル使用メモリ | 121,380 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2024-09-14 23:29:21 |
合計ジャッジ時間 | 10,879 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 3 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 3 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 2 ms
5,376 KB |
testcase_58 | AC | 2 ms
5,376 KB |
testcase_59 | AC | 2 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | AC | 2 ms
5,376 KB |
testcase_62 | AC | 2 ms
5,376 KB |
testcase_63 | AC | 2 ms
5,376 KB |
testcase_64 | AC | 2 ms
5,376 KB |
testcase_65 | AC | 2 ms
5,376 KB |
testcase_66 | AC | 2 ms
5,376 KB |
testcase_67 | AC | 2 ms
5,376 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 2 ms
5,376 KB |
testcase_70 | AC | 2 ms
5,376 KB |
testcase_71 | AC | 2 ms
5,376 KB |
testcase_72 | AC | 2 ms
5,376 KB |
testcase_73 | AC | 2 ms
5,376 KB |
testcase_74 | AC | 2 ms
5,376 KB |
testcase_75 | AC | 2 ms
5,376 KB |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | AC | 2 ms
5,376 KB |
testcase_78 | AC | 3 ms
5,376 KB |
testcase_79 | AC | 2 ms
5,376 KB |
testcase_80 | AC | 2 ms
5,376 KB |
testcase_81 | AC | 2 ms
5,376 KB |
testcase_82 | AC | 2 ms
5,376 KB |
testcase_83 | AC | 2 ms
5,376 KB |
testcase_84 | AC | 2 ms
5,376 KB |
testcase_85 | AC | 2 ms
5,376 KB |
testcase_86 | AC | 2 ms
5,376 KB |
testcase_87 | AC | 2 ms
5,376 KB |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | AC | 2 ms
5,376 KB |
testcase_93 | AC | 2 ms
5,376 KB |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | AC | 2 ms
5,376 KB |
testcase_99 | AC | 2 ms
5,376 KB |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | AC | 2 ms
5,376 KB |
testcase_104 | AC | 2 ms
5,376 KB |
testcase_105 | AC | 2 ms
5,376 KB |
testcase_106 | WA | - |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | AC | 2 ms
5,376 KB |
testcase_111 | AC | 2 ms
5,376 KB |
testcase_112 | AC | 2 ms
5,376 KB |
testcase_113 | AC | 2 ms
5,376 KB |
testcase_114 | AC | 2 ms
5,376 KB |
testcase_115 | AC | 2 ms
5,376 KB |
testcase_116 | AC | 2 ms
5,376 KB |
testcase_117 | AC | 2 ms
5,376 KB |
testcase_118 | AC | 2 ms
5,376 KB |
testcase_119 | AC | 2 ms
5,376 KB |
testcase_120 | AC | 2 ms
5,376 KB |
testcase_121 | AC | 2 ms
5,376 KB |
testcase_122 | AC | 2 ms
5,376 KB |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | AC | 2 ms
5,376 KB |
testcase_125 | AC | 2 ms
5,376 KB |
testcase_126 | AC | 2 ms
5,376 KB |
testcase_127 | AC | 2 ms
5,376 KB |
testcase_128 | AC | 29 ms
5,376 KB |
testcase_129 | AC | 75 ms
5,888 KB |
testcase_130 | AC | 54 ms
5,376 KB |
testcase_131 | AC | 93 ms
6,400 KB |
testcase_132 | AC | 76 ms
6,272 KB |
testcase_133 | AC | 3 ms
5,376 KB |
testcase_134 | AC | 23 ms
5,376 KB |
testcase_135 | AC | 27 ms
5,376 KB |
testcase_136 | AC | 27 ms
5,376 KB |
testcase_137 | AC | 44 ms
5,376 KB |
testcase_138 | AC | 56 ms
5,376 KB |
testcase_139 | AC | 66 ms
5,760 KB |
testcase_140 | AC | 89 ms
6,528 KB |
testcase_141 | AC | 86 ms
6,400 KB |
testcase_142 | AC | 37 ms
5,376 KB |
testcase_143 | AC | 55 ms
5,504 KB |
testcase_144 | AC | 71 ms
6,016 KB |
testcase_145 | AC | 7 ms
5,376 KB |
testcase_146 | AC | 18 ms
5,376 KB |
testcase_147 | AC | 59 ms
5,504 KB |
testcase_148 | AC | 32 ms
5,376 KB |
testcase_149 | AC | 50 ms
5,376 KB |
testcase_150 | AC | 71 ms
5,888 KB |
testcase_151 | AC | 5 ms
5,376 KB |
testcase_152 | AC | 62 ms
5,504 KB |
testcase_153 | AC | 92 ms
6,784 KB |
testcase_154 | AC | 4 ms
5,376 KB |
testcase_155 | AC | 65 ms
5,632 KB |
testcase_156 | AC | 22 ms
5,376 KB |
testcase_157 | AC | 63 ms
5,760 KB |
testcase_158 | AC | 85 ms
6,656 KB |
testcase_159 | AC | 13 ms
5,376 KB |
testcase_160 | AC | 6 ms
5,376 KB |
testcase_161 | AC | 73 ms
6,016 KB |
testcase_162 | AC | 79 ms
6,272 KB |
testcase_163 | AC | 45 ms
5,376 KB |
testcase_164 | AC | 84 ms
6,400 KB |
testcase_165 | AC | 68 ms
5,632 KB |
testcase_166 | AC | 13 ms
5,376 KB |
testcase_167 | AC | 43 ms
5,376 KB |
testcase_168 | AC | 29 ms
5,376 KB |
testcase_169 | AC | 31 ms
5,376 KB |
testcase_170 | AC | 25 ms
5,376 KB |
testcase_171 | AC | 44 ms
5,376 KB |
testcase_172 | AC | 33 ms
5,376 KB |
testcase_173 | AC | 8 ms
5,376 KB |
testcase_174 | AC | 75 ms
6,016 KB |
testcase_175 | AC | 90 ms
6,528 KB |
testcase_176 | AC | 62 ms
5,632 KB |
testcase_177 | AC | 9 ms
5,376 KB |
testcase_178 | AC | 64 ms
5,632 KB |
testcase_179 | AC | 69 ms
5,888 KB |
testcase_180 | AC | 86 ms
6,144 KB |
testcase_181 | AC | 19 ms
5,376 KB |
testcase_182 | AC | 38 ms
5,376 KB |
testcase_183 | AC | 52 ms
5,376 KB |
testcase_184 | AC | 40 ms
5,376 KB |
testcase_185 | AC | 63 ms
5,504 KB |
testcase_186 | AC | 77 ms
6,016 KB |
testcase_187 | AC | 58 ms
5,504 KB |
testcase_188 | AC | 2 ms
5,376 KB |
testcase_189 | AC | 2 ms
5,376 KB |
testcase_190 | AC | 2 ms
5,376 KB |
testcase_191 | AC | 2 ms
5,376 KB |
testcase_192 | AC | 2 ms
5,376 KB |
testcase_193 | AC | 2 ms
5,376 KB |
testcase_194 | AC | 2 ms
5,376 KB |
testcase_195 | AC | 2 ms
5,376 KB |
testcase_196 | WA | - |
testcase_197 | WA | - |
testcase_198 | WA | - |
testcase_199 | WA | - |
testcase_200 | AC | 73 ms
6,016 KB |
testcase_201 | AC | 41 ms
5,376 KB |
testcase_202 | WA | - |
testcase_203 | WA | - |
testcase_204 | WA | - |
testcase_205 | WA | - |
testcase_206 | AC | 81 ms
6,400 KB |
testcase_207 | AC | 60 ms
5,632 KB |
testcase_208 | WA | - |
testcase_209 | WA | - |
testcase_210 | WA | - |
testcase_211 | WA | - |
testcase_212 | AC | 20 ms
5,376 KB |
testcase_213 | AC | 43 ms
5,376 KB |
testcase_214 | WA | - |
testcase_215 | WA | - |
testcase_216 | WA | - |
testcase_217 | WA | - |
testcase_218 | AC | 85 ms
6,528 KB |
testcase_219 | AC | 45 ms
5,376 KB |
ソースコード
#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); ll ans=x[0]*y[0]+(w-x[n-1]+1)*(h-y[n-1]+1); if(n==2) ans+=x[n-1]-x[0]-1; cout<<ans<<endl; return 0; } if(y1[0]==y1[n-1]){ sort(x, x+n); sort(y, y+n); ll ans=(w-x[n-1]+1)*y[0]+x[0]*(h-y[n-1]+1); if(n==2) ans+=x[n-1]-x[0]-1; cout<<ans<<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}); } } } } if(st.empty()){ cout<<0<<endl; return 0; } const ll INF=1e18; ll ans=0; 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) ans+=max(0ll, h-y0+1); }else if(!dame2){ if(1<=x0 && x0<=w) ans+=max(0ll, y0); } 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) ans+=max(0ll, w-x0+1); }else if(!dame2){ if(1<=y0 && y0<=h) ans+=max(0ll, x0); } } if(st.size()==1){ cout<<max(1ll, ans)<<endl; return 0; } assert(st.size()==2); ans=max(ans, 2ll); ll ax[2], ay[2]; int c=0; for(auto p:st){ ax[c]=p.first, ay[c]=p.second; c++; } if(ay[0]<ay[1]){ ll mn=max({0ll, 1-ax[0], 1-ay[0]}), mx=min({ax[1]-ax[0], w-ax[0], h-ay[0]}); ans+=max(0ll, mx-mn-1); }else{ ll mn=max({0ll, 1-ax[0], ay[0]-h}), mx=min({ax[1]-ax[0], w-ax[0], ay[0]-1}); ans+=max(0ll, mx-mn-1); } cout<<ans<<endl; return 0; }