#include <iostream> #include <vector> #include <bitset> #include <algorithm> typedef long long ll; struct T { int p, e, d, ab, mn; bool operator < (const T& o) const { if (p != o.p) return p < o.p; if (e != o.e) return e > o.e; if (mn != o.mn) return mn < o.mn; if (d != o.d) return d < o.d; if (ab != o.ab) return ab < o.ab; return false; } }; bool cmp(const T& a, const T& b) { if (a.p != b.p) return a.p < b.p; if (a.e != b.e) return a.e > b.e; if (a.mn != b.mn) return a.mn > b.mn; if (a.d != b.d) return a.d > b.d; if (a.ab != b.ab) return a.ab > b.ab; return false; } int n; int X, Y; int x1, x2, y1, y2; int kon_i, kon_j; std::vector<T> vx, vy, vxc, vyc; int main() { std::cin >> n >> X >> Y; for (int i = 0; i < n; ++i) { std::cin >> x1 >> y1 >> x2 >> y2; if (x1 > x2) std::swap(x1, x2); if (y1 > y2) std::swap(y1, y2); vx.push_back({x1, 0, i, 0, 0}); vx.push_back({x2, 1, i, 0, 0}); if (x1 != 0 && x2 != X) { vx.push_back({0, 0, i, 1, 1}); vx.push_back({x1, 1, i, 1, 1}); vx.push_back({x2, 0, i, 1, 1}); vx.push_back({X, 1, i, 1, 1}); } else if (x1 != 0) { vx.push_back({0, 0, i, 1, 0}); vx.push_back({x1, 1, i, 1, 0}); } else if (x2 != X) { vx.push_back({x2, 0, i, 1, 0}); vx.push_back({X, 1, i, 1, 0}); } vy.push_back({y1, 0, i, 0, 0}); vy.push_back({y2, 1, i, 0, 0}); if (y1 != 0 && y2 != Y) { vy.push_back({0, 0, i, 1, 1}); vy.push_back({y1, 1, i, 1, 1}); vy.push_back({y2, 0, i, 1, 1}); vy.push_back({Y, 1, i, 1, 1}); } else if (y1 != 0) { vy.push_back({0, 0, i, 1, 0}); vy.push_back({y1, 1, i, 1, 0}); } else if (y2 != Y) { vy.push_back({y2, 0, i, 1, 0}); vy.push_back({Y, 1, i, 1, 0}); } } std::sort(vx.begin(), vx.end()); std::sort(vy.begin(), vy.end()); vxc = vx; vyc = vy; std::sort(vxc.begin(), vxc.end(), cmp); std::sort(vyc.begin(), vyc.end(), cmp); int cnt = 0; for (auto & i : vx) { // std::cout << cnt++ << ": " << i.p << " " << i.e << " " << i.d << " " << i.ab << " " << i.mn << std::endl; } // std::cout << std::endl; cnt = 0; for (auto & i : vxc) { // std::cout << cnt++ << ": " << i.p << " " << i.e << " " << i.d << " " << i.ab << " " << i.mn << std::endl; } int roz = n; std::vector<bool> b(n * 2, 0); std::vector<bool> zak(n * 2, 0); int i, j; int skok_i = 0, skok_j = X; int res_x = 0; for (i = 0; i < n; ++i) { // std::cout << i << "++ " << j << " " << std::endl; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << ":: " << vx[i].d * 2 + vx[i].ab << std::endl; } for (j = vxc.size() - 1; j > vxc.size() - 1 - n; --j) { // std::cout << i << " " << j << "-- " << std::endl; if (b[vxc[j].d * 2 + vxc[j].ab] == 1) { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << " " << vxc[j].d * 2 + vxc[j].ab << std::endl; } else { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << vxc[j].d * 2 + vxc[j].ab << std::endl; } } while (i <= j) { if (vx[i].p != vx[i - 1].p) skok_i = vx[i - 1].p; if (vxc[j].p != vxc[j + 1].p) skok_j = vxc[j + 1].p; if (vx[i].mn == 0) { // std::cout << "c " << i << "++ " << j << " " << std::endl; res_x = std::max(res_x, vx[i].p - skok_i); // std::cout << res_x << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } else if (vxc[j].mn == 0) { // std::cout << "d " << i << " " << j << "-- " << std::endl; res_x = std::max(res_x, skok_j - vxc[j].p); // std::cout << res_x << std::endl; if (b[vxc[j].d * 2 + vxc[j].ab] == 0) { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } else { if (roz == 0) { // std::cout << "e " << i << "++ " << j << "-- " << std::endl; res_x = std::max(res_x, (vx[i].p - skok_i) + (skok_j - vxc[j].p)); // std::cout << res_x << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } if (b[vxc[j].d * 2 + vxc[j].ab] == 0) { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; --j; } else { // std::cout << "f " << i << "++ " << j << " " << std::endl; res_x = std::max(res_x, vx[i].p - skok_i); // std::cout << res_x << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } } while (i <= j && vx[i].e == 0) { // std::cout << "a " << i << "++ " << j << " " << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } while (i <= j && vxc[j].e == 1) { // std::cout << "b " << i << " " << j << "-- " << std::endl; if (b[vxc[j].d * 2 + vxc[j].ab] == 0) { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } } if (i - 1 == j && vx[i].p != vxc[j].p) { res_x = std::max(res_x, std::abs(vxc[j].p - vx[i].p)); } // std::cout << res_x << std::endl; /***************/ cnt = 0; for (auto & i : vy) { // std::cout << cnt++ << ": " << i.p << " " << i.e << " " << i.d << " " << i.ab << " " << i.mn << std::endl; } roz = n; b.clear(); b.resize(n * 2, 0); zak.clear(); zak.resize(n * 2, 0); i = j = 0; skok_i = 0; skok_j = Y; int res_y = 0; for (i = 0; i < n; ++i) { // std::cout << i << "++ " << j << " " << std::endl; b[vy[i].d * 2 + vy[i].ab] = 1; } for (j = vy.size() - 1; j > vy.size() - 1 - n; --j) { // std::cout << i << " " << j << "-- " << std::endl; if (b[vyc[j].d * 2 + vyc[j].ab] == 1) { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << " -" << std::endl; } else { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << " +" << std::endl; } } while (i <= j) { if (vy[i].p != vy[i - 1].p) skok_i = vy[i - 1].p; if (vyc[j].p != vyc[j + 1].p) skok_j = vyc[j + 1].p; if (vy[i].mn == 0) { // std::cout << "c " << i << "++ " << j << " " << std::endl; res_y = std::max(res_y, vy[i].p - skok_i); // std::cout << res_y << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } else if (vyc[j].mn == 0) { // std::cout << "d " << i << " " << j << "-- " << std::endl; res_y = std::max(res_y, skok_j - vyc[j].p); // std::cout << res_y << std::endl; if (b[vyc[j].d * 2 + vyc[j].ab] == 0) { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } else { // std::cout << ">>" << vy[i].d << " " << vyc[j].d << std::endl; if (roz == 0) { // std::cout << "e " << i << "++ " << j << "-- " << std::endl; res_y = std::max(res_y, (vy[i].p - skok_i) + (skok_j - vyc[j].p)); // std::cout << res_y << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } if (b[vyc[j].d * 2 + vyc[j].ab] == 0) { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; --j; } else { // std::cout << "f " << i << "++ " << j << " " << std::endl; res_y = std::max(res_y, vy[i].p - skok_i); // std::cout << res_y << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } } while (i <= j && vy[i].e == 0) { // std::cout << "a " << i << "++ " << j << " " << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } while (i <= j && vyc[j].e == 1) { // std::cout << "b " << i << " " << j << "-- " << std::endl; if (b[vyc[j].d * 2 + vyc[j].ab] == 0) { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } } if (i - 1 == j && vy[i].p != vyc[j].p) { res_y = std::max(res_y, std::abs(vyc[j].p - vy[i].p)); } // std::cout << res_y << std::endl; std::cout << (long long)res_y * (long long)res_x << std::endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | #include <iostream> #include <vector> #include <bitset> #include <algorithm> typedef long long ll; struct T { int p, e, d, ab, mn; bool operator < (const T& o) const { if (p != o.p) return p < o.p; if (e != o.e) return e > o.e; if (mn != o.mn) return mn < o.mn; if (d != o.d) return d < o.d; if (ab != o.ab) return ab < o.ab; return false; } }; bool cmp(const T& a, const T& b) { if (a.p != b.p) return a.p < b.p; if (a.e != b.e) return a.e > b.e; if (a.mn != b.mn) return a.mn > b.mn; if (a.d != b.d) return a.d > b.d; if (a.ab != b.ab) return a.ab > b.ab; return false; } int n; int X, Y; int x1, x2, y1, y2; int kon_i, kon_j; std::vector<T> vx, vy, vxc, vyc; int main() { std::cin >> n >> X >> Y; for (int i = 0; i < n; ++i) { std::cin >> x1 >> y1 >> x2 >> y2; if (x1 > x2) std::swap(x1, x2); if (y1 > y2) std::swap(y1, y2); vx.push_back({x1, 0, i, 0, 0}); vx.push_back({x2, 1, i, 0, 0}); if (x1 != 0 && x2 != X) { vx.push_back({0, 0, i, 1, 1}); vx.push_back({x1, 1, i, 1, 1}); vx.push_back({x2, 0, i, 1, 1}); vx.push_back({X, 1, i, 1, 1}); } else if (x1 != 0) { vx.push_back({0, 0, i, 1, 0}); vx.push_back({x1, 1, i, 1, 0}); } else if (x2 != X) { vx.push_back({x2, 0, i, 1, 0}); vx.push_back({X, 1, i, 1, 0}); } vy.push_back({y1, 0, i, 0, 0}); vy.push_back({y2, 1, i, 0, 0}); if (y1 != 0 && y2 != Y) { vy.push_back({0, 0, i, 1, 1}); vy.push_back({y1, 1, i, 1, 1}); vy.push_back({y2, 0, i, 1, 1}); vy.push_back({Y, 1, i, 1, 1}); } else if (y1 != 0) { vy.push_back({0, 0, i, 1, 0}); vy.push_back({y1, 1, i, 1, 0}); } else if (y2 != Y) { vy.push_back({y2, 0, i, 1, 0}); vy.push_back({Y, 1, i, 1, 0}); } } std::sort(vx.begin(), vx.end()); std::sort(vy.begin(), vy.end()); vxc = vx; vyc = vy; std::sort(vxc.begin(), vxc.end(), cmp); std::sort(vyc.begin(), vyc.end(), cmp); int cnt = 0; for (auto & i : vx) { // std::cout << cnt++ << ": " << i.p << " " << i.e << " " << i.d << " " << i.ab << " " << i.mn << std::endl; } // std::cout << std::endl; cnt = 0; for (auto & i : vxc) { // std::cout << cnt++ << ": " << i.p << " " << i.e << " " << i.d << " " << i.ab << " " << i.mn << std::endl; } int roz = n; std::vector<bool> b(n * 2, 0); std::vector<bool> zak(n * 2, 0); int i, j; int skok_i = 0, skok_j = X; int res_x = 0; for (i = 0; i < n; ++i) { // std::cout << i << "++ " << j << " " << std::endl; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << ":: " << vx[i].d * 2 + vx[i].ab << std::endl; } for (j = vxc.size() - 1; j > vxc.size() - 1 - n; --j) { // std::cout << i << " " << j << "-- " << std::endl; if (b[vxc[j].d * 2 + vxc[j].ab] == 1) { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << " " << vxc[j].d * 2 + vxc[j].ab << std::endl; } else { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << vxc[j].d * 2 + vxc[j].ab << std::endl; } } while (i <= j) { if (vx[i].p != vx[i - 1].p) skok_i = vx[i - 1].p; if (vxc[j].p != vxc[j + 1].p) skok_j = vxc[j + 1].p; if (vx[i].mn == 0) { // std::cout << "c " << i << "++ " << j << " " << std::endl; res_x = std::max(res_x, vx[i].p - skok_i); // std::cout << res_x << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } else if (vxc[j].mn == 0) { // std::cout << "d " << i << " " << j << "-- " << std::endl; res_x = std::max(res_x, skok_j - vxc[j].p); // std::cout << res_x << std::endl; if (b[vxc[j].d * 2 + vxc[j].ab] == 0) { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } else { if (roz == 0) { // std::cout << "e " << i << "++ " << j << "-- " << std::endl; res_x = std::max(res_x, (vx[i].p - skok_i) + (skok_j - vxc[j].p)); // std::cout << res_x << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } if (b[vxc[j].d * 2 + vxc[j].ab] == 0) { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; --j; } else { // std::cout << "f " << i << "++ " << j << " " << std::endl; res_x = std::max(res_x, vx[i].p - skok_i); // std::cout << res_x << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } } while (i <= j && vx[i].e == 0) { // std::cout << "a " << i << "++ " << j << " " << std::endl; if (b[vx[i].d * 2 + vx[i].ab] == 0) { roz++; b[vx[i].d * 2 + vx[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vx[i].d * 2 + vx[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } while (i <= j && vxc[j].e == 1) { // std::cout << "b " << i << " " << j << "-- " << std::endl; if (b[vxc[j].d * 2 + vxc[j].ab] == 0) { roz++; b[vxc[j].d * 2 + vxc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vxc[j].d * 2 + vxc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } } if (i - 1 == j && vx[i].p != vxc[j].p) { res_x = std::max(res_x, std::abs(vxc[j].p - vx[i].p)); } // std::cout << res_x << std::endl; /***************/ cnt = 0; for (auto & i : vy) { // std::cout << cnt++ << ": " << i.p << " " << i.e << " " << i.d << " " << i.ab << " " << i.mn << std::endl; } roz = n; b.clear(); b.resize(n * 2, 0); zak.clear(); zak.resize(n * 2, 0); i = j = 0; skok_i = 0; skok_j = Y; int res_y = 0; for (i = 0; i < n; ++i) { // std::cout << i << "++ " << j << " " << std::endl; b[vy[i].d * 2 + vy[i].ab] = 1; } for (j = vy.size() - 1; j > vy.size() - 1 - n; --j) { // std::cout << i << " " << j << "-- " << std::endl; if (b[vyc[j].d * 2 + vyc[j].ab] == 1) { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << " -" << std::endl; } else { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << " +" << std::endl; } } while (i <= j) { if (vy[i].p != vy[i - 1].p) skok_i = vy[i - 1].p; if (vyc[j].p != vyc[j + 1].p) skok_j = vyc[j + 1].p; if (vy[i].mn == 0) { // std::cout << "c " << i << "++ " << j << " " << std::endl; res_y = std::max(res_y, vy[i].p - skok_i); // std::cout << res_y << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } else if (vyc[j].mn == 0) { // std::cout << "d " << i << " " << j << "-- " << std::endl; res_y = std::max(res_y, skok_j - vyc[j].p); // std::cout << res_y << std::endl; if (b[vyc[j].d * 2 + vyc[j].ab] == 0) { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } else { // std::cout << ">>" << vy[i].d << " " << vyc[j].d << std::endl; if (roz == 0) { // std::cout << "e " << i << "++ " << j << "-- " << std::endl; res_y = std::max(res_y, (vy[i].p - skok_i) + (skok_j - vyc[j].p)); // std::cout << res_y << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } if (b[vyc[j].d * 2 + vyc[j].ab] == 0) { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; --j; } else { // std::cout << "f " << i << "++ " << j << " " << std::endl; res_y = std::max(res_y, vy[i].p - skok_i); // std::cout << res_y << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } } while (i <= j && vy[i].e == 0) { // std::cout << "a " << i << "++ " << j << " " << std::endl; if (b[vy[i].d * 2 + vy[i].ab] == 0) { roz++; b[vy[i].d * 2 + vy[i].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vy[i].d * 2 + vy[i].ab] = 0; // std::cout << roz << "-" << std::endl; } ++i; } while (i <= j && vyc[j].e == 1) { // std::cout << "b " << i << " " << j << "-- " << std::endl; if (b[vyc[j].d * 2 + vyc[j].ab] == 0) { roz++; b[vyc[j].d * 2 + vyc[j].ab] = 1; // std::cout << roz << "+" << std::endl; } else { roz--; b[vyc[j].d * 2 + vyc[j].ab] = 0; // std::cout << roz << "-" << std::endl; } --j; } } if (i - 1 == j && vy[i].p != vyc[j].p) { res_y = std::max(res_y, std::abs(vyc[j].p - vy[i].p)); } // std::cout << res_y << std::endl; std::cout << (long long)res_y * (long long)res_x << std::endl; return 0; } |