File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77#include < vector>
88
99template <class T >
10- inline void chkmax (T &x, T y) {
11- if (x < y) x = y;
10+ inline bool chkmax (T &x, T y) {
11+ if (x < y) {
12+ x = y;
13+ return true ;
14+ }
15+ return false ;
1216}
1317
1418template <class T >
15- inline void chkmin (T &x, T y) {
16- if (x > y) x = y;
19+ inline bool chkmin (T &x, T y) {
20+ if (x > y) {
21+ x = y;
22+ return true ;
23+ }
24+ return false ;
1725}
1826
1927template <class T >
Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ inline void Yes_No(bool cond) { cond ? Yes() : No(); }
6262
6363std::ostream &operator<<(std::ostream &os, i128 n) {
6464 std::string s;
65+ if (n == 0) {
66+ return os << "0";
67+ }
6568 if (n < 0) {
6669 os << '-', n = -n;
6770 }
Original file line number Diff line number Diff line change @@ -32,6 +32,26 @@ inline T isqrt(T x) {
3232 return res;
3333}
3434
35+ using i128 = __int128;
36+
37+ template <>
38+ inline i128 isqrt<i128 >(i128 x) {
39+ i128 L = 0 , R = 13043817825332782ll , mid;
40+ while (L < R) {
41+ mid = (L + R + 1 ) >> 1 ;
42+ if (mid * mid > x) {
43+ R = mid - 1 ;
44+ } else {
45+ L = mid;
46+ }
47+ }
48+ return L;
49+ }
50+
51+ inline i128 abs128 (i128 x) {
52+ return x < 0 ? -x : x;
53+ }
54+
3555template <class T , class V >
3656inline bool in_range (V v, T l, T r) {
3757 return l <= v && v <= r;
Original file line number Diff line number Diff line change @@ -55,14 +55,14 @@ struct SingleHash {
5555};
5656
5757struct HashedString {
58- using SH1 = SingleHash<
58+ SingleHash<
5959 ctrandom::MOD_POOL[ctrandom::pick_idx1()],
60- ctrandom::SEED_POOL[ctrandom::pick_idx1()]>;
61- using SH2 = SingleHash<
60+ ctrandom::SEED_POOL[ctrandom::pick_idx1()]>
61+ H1;
62+ SingleHash<
6263 ctrandom::MOD_POOL[ctrandom::pick_idx2()],
63- ctrandom::SEED_POOL[ctrandom::pick_idx2()]>;
64- SH1 H1;
65- SH2 H2;
64+ ctrandom::SEED_POOL[ctrandom::pick_idx2()]>
65+ H2;
6666 HashedString (void ) = default;
6767 HashedString (std::string s) : H1(s), H2(s) {}
6868 inline void init (std::string s) {
You can’t perform that action at this time.
0 commit comments