[kuangbin带你飞7]线段树

kuangbin带你飞7 前言 作为一名acm选手,不能连线段树都不会,练就完事了。而且我越发觉得在赛场上不能卡机,中档题才是区分牌子的题目。只有慢慢思索的题目才能真正地提高自己,立下一个flag,每十天完成一个kuangbin专题。现在时间9/6。必须在9/16完成这个线段树专题,就算是困死也得完成。 ...

September 6, 2018 · 5 min · CheaSim

[nowcoder3]补题向

J.Coloring Tree 题意 给一棵树,每个节点从$[1,k]$选择一种颜色染。定义树的颜色值为两个相同颜色节点之间的最小值。问如果一棵树的颜色值为$D$,那么它有多少种染色方式。 ...

September 5, 2018 · 1 min · CheaSim

计算几何模板

J .Distance to work 题意 懒得看了 题解 计算几何。 扒一扒dls的板子 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 typedef const inline inline struct db x, y; P() {} P(db _x, db _y) : x(_x), y(_y) {} P operator P operator P operator P operator bool int if return } bool return } db dot db det db distTo db alpha void void db abs db abs2 P rot90 P unit int P rot }; struct P ps[2 L() {} L(P p1,P p2) { ps[0 P& operator P dir bool L push const P delta = (ps[1 return } }; 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 #define #define bool db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2); return } P isLL db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2); return } P isLL bool if return } bool return crossOp(p1,p2,q1) * crossOp(p1,p2,q2) 0 } return } vector int sort(ps.begin(), ps.end()); vector for while for while qs.resize(k - 1 return } vector //caution: need to unique the Ps first int sort(ps.begin(), ps.end()); vector for while for while qs.resize(k - 1 return } db convexDiameter int int int db ret = ps[i].distTo(ps[j]); do if (++j)%=n; else (++i)%=n; ret = max(ret,ps[i].distTo(ps[j])); }while return } vector vector int rep(i,0 P p1 = ps[i], p2 = ps[(i+1 int if if } return } //min_dist 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 db min_dist if db ret = 1e100 rep(i,l,r) rep(j,l,i) ret = min(ret,ps[i].distTo(ps[j])); return } int db ret = min(min_dist(ps,l,m),min_dist(ps,m,r)); vector sort(qs.begin(), qs.end(),[](P a,P b) -> bool rep(i,1 ret = min(ret,qs[i].distTo(qs[j])); return } int db d = o1.distTo(o2); if if if if return } vector db x = (p1-o).dot(p2-p1), y = (p2-p1).abs2(), d = x * x - y * ((p1-o).abs2() - r*r); if d = max(d,0.0 return } vector db d = o1.distTo(o2); if if d = min(d, r1 + r2); db y = (r1 * r1 + d * d - r2 * r2) / (2 P dr = (o2 - o1).unit(); P q1 = o1 + dr * y, q2 = dr.rot90() * x; return } vector db x = (p - o).abs2(), d = x - r * r; if P q1 = o + (p - o) * (r * r / x); P q2 = (p - o).rot90() * (r * sqrt return } vector vector if P dr = (o2 - o1).unit().rot90() * r1; ret.pb(L(o1 + dr, o2 + dr)), ret.pb(L(o1 - dr, o2 - dr)); } else P p = (o2 * r1 - o1 * r2) / (r1 - r2); vector rep(i,0 } return } vector vector P p = (o1 * r2 + o2 * r1) / (r1 + r2); vector rep(i,0 return } db areaCT vector if bool if if sign((p1-is[0 return else } if if return } bool bool bool if return } else return } } bool if return } else return } } bool return } vector sort(l.begin(), l.end()); deque for if while while q.push_back(l[i]); } while while vector for return } P inCenter double return } P circumCenter P bb = b - a, cc = c - a; double return } P othroCenter P ba = b - a, ca = c - a, bc = b - c; double A = ca.x * ba.y - ba.x * ca.y, x0 = (Y + ca.x * ba.y * b.x - ba.x * ca.y * c.x) / A, y0 = -ba.x * (x0 - c.x) / ba.y + ca.y; return } AC代码(别人家的模板。) 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 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 #include using #define const const const const // Compares a double to zero int if if return else return } // square of a double inline return } /* 15 * Point 16 * Point() - Empty constructor 17 * Point(double _x,double _y) - constructor 18 * input() - double input 19 * output() - %.2f output 20 * operator == - compares x and y 21 * operator 作者 CheaSim 发布于 2018-09-05 更新于 2018-09-05 许可协议 #[计算几何](/tags/%E8%AE%A1%E7%AE%97%E5%87%A0%E4%BD%95/)

September 5, 2018 · 4 min · CheaSim

2018 ICPC南京赛区网络赛

ACM-ICPC 2018 南京赛区网络预赛 A. An Olympian Math Problem 题意 $S=1×1!+2×2!+⋯+(n - 1) \times (n-1)!(n−1)×(n−1)!$问$Smodn$是多少。 题解 思维题,打表题?答案就是$n-1$证明如下。 ...

September 3, 2018 · 4 min · CheaSim

web应用开发笔记

web应用开发 现代人的生活方式 移动端,mobile 浏览器,browser 10年前还是以客户端,client软件形式。 两个主流技术 .Net J2ee .Net过气了,用J2ee J2ee的三个方面 M 模型:负责数据方面的事情,数据分为两个方面,store存储,access访问。依靠模型完成这个功能。 承载数据。 ...

September 3, 2018 · 3 min · CheaSim

回文树学习笔记

回文树学习笔记 神奇的数据结构 Palindromic Tree 回文树 功能简介 求一个串$S$中$[0,i]$中本质不同回文串的个数 求串$S$中每一个本质不同回文串出现的次数 求指定下标$i$结尾的回文串的个数 变量简介 $len[i]$表示编号为$i$节点所表示的回文串的$len$。 ...

September 3, 2018 · 2 min · CheaSim

Codeforces Round #499 (Div. 2)

Codeforces Round #499 (Div. 2)](http://codeforces.com/contest/1011) A. Stages 题意 给定一段序列,每个字母代表这一个权值,比如$a$代表$1$。之后问从中挑选出一个序列,要求$a[i]$和$a[i+1]$之间相隔一个字母,问从任意顺序选择$k$个字母,最少可以有多少权值。 ...

September 2, 2018 · 1 min · CheaSim

[hdoj4616] Game

Game 题意 给一颗树,已知每个点有权值和陷阱,你不能往回走,如果走过$c$个陷阱或者无路可走就结束,可以从任一点开始走,问能获得多少权值。 题解 树形dp。 $dp[i][j][0/1]$是在以$i$为终点,经过$j$个陷阱,$1$代表起点有陷阱,$0$代表起点没有陷阱。转移方程 ...

August 31, 2018 · 2 min · CheaSim

八数码问题

八数码问题 前提知识 康拓展开 用途 相当于hash存储序列,使用更加小的空间来存储排列。 公式 $X = a_n*(n-1)!+a_{n-1}(n-2)+…+a_10!$,$a_i$表示当前未出现的数字是排在第几个元素。$0 \leq a_i 八数码问题 ...

August 31, 2018 · 1 min · CheaSim

[hdoj1556]Color the ball

Color the ball 题意 给定$n$次操作,吧$l,r$区间内+1,最后问每个点是多少。 题解 树状数组骚操作。 既然我单点更新只能更新一个点,那么我就更新$l$点加上1,之后$r+1$的点减1,那么我对于在区间中的点,求得就是他之前$l$出现的次数。 ...

August 30, 2018 · 1 min · CheaSim