diff --git a/content/contest/template.cpp b/content/contest/template.cpp index ac5ff7189..b9e76ccda 100644 --- a/content/contest/template.cpp +++ b/content/contest/template.cpp @@ -4,9 +4,9 @@ using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() -typedef long long ll; -typedef pair pii; -typedef vector vi; +using ll = long long; +using pii = pair; +using vi = vector; int main() { cin.tie(0)->sync_with_stdio(0); diff --git a/content/data-structures/Matrix.h b/content/data-structures/Matrix.h index 642ef7ace..5b7341e43 100644 --- a/content/data-structures/Matrix.h +++ b/content/data-structures/Matrix.h @@ -13,7 +13,7 @@ #pragma once template struct Matrix { - typedef Matrix M; + using M = Matrix; array, N> d{}; M operator*(const M& m) const { M a; diff --git a/content/data-structures/SegmentTree.h b/content/data-structures/SegmentTree.h index d03106c8e..13388fc49 100644 --- a/content/data-structures/SegmentTree.h +++ b/content/data-structures/SegmentTree.h @@ -11,7 +11,7 @@ #pragma once struct Tree { - typedef int T; + using T = int; static constexpr T unit = INT_MIN; T f(T a, T b) { return max(a, b); } // (any associative fn) vector s; int n; diff --git a/content/geometry/3dHull.h b/content/geometry/3dHull.h index aeda36a0e..0deb1e701 100644 --- a/content/geometry/3dHull.h +++ b/content/geometry/3dHull.h @@ -12,7 +12,7 @@ #include "Point3D.h" -typedef Point3D P3; +using P3 = Point3D; struct PR { void ins(int x) { (a == -1 ? a : b) = x; } diff --git a/content/geometry/CircleIntersection.h b/content/geometry/CircleIntersection.h index f406cd341..1e5d48df1 100644 --- a/content/geometry/CircleIntersection.h +++ b/content/geometry/CircleIntersection.h @@ -10,7 +10,7 @@ #include "Point.h" -typedef Point P; +using P = Point; bool circleInter(P a,P b,double r1,double r2,pair* out) { if (a == b) { assert(r1 != r2); return false; } P vec = b - a; diff --git a/content/geometry/CirclePolygonIntersection.h b/content/geometry/CirclePolygonIntersection.h index ab8e72030..32bc56ed6 100644 --- a/content/geometry/CirclePolygonIntersection.h +++ b/content/geometry/CirclePolygonIntersection.h @@ -12,7 +12,7 @@ #include "../../content/geometry/Point.h" -typedef Point P; +using P = Point; #define arg(p, q) atan2(p.cross(q), p.dot(q)) double circlePoly(P c, double r, vector

ps) { auto tri = [&](P p, P q) { diff --git a/content/geometry/ClosestPair.h b/content/geometry/ClosestPair.h index bd5adcb01..68fb032e0 100644 --- a/content/geometry/ClosestPair.h +++ b/content/geometry/ClosestPair.h @@ -11,7 +11,7 @@ #include "Point.h" -typedef Point P; +using P = Point; pair closest(vector

v) { assert(sz(v) > 1); set

S; diff --git a/content/geometry/ConvexHull.h b/content/geometry/ConvexHull.h index b38a37a6a..d253d0100 100644 --- a/content/geometry/ConvexHull.h +++ b/content/geometry/ConvexHull.h @@ -20,7 +20,7 @@ Points on the edge of the hull between two other points are not considered part #include "Point.h" -typedef Point P; +using P = Point; vector

convexHull(vector

pts) { if (sz(pts) <= 1) return pts; sort(all(pts)); diff --git a/content/geometry/FastDelaunay.h b/content/geometry/FastDelaunay.h index 66139d55f..c657bb6bc 100644 --- a/content/geometry/FastDelaunay.h +++ b/content/geometry/FastDelaunay.h @@ -16,9 +16,9 @@ #include "Point.h" -typedef Point P; -typedef struct Quad* Q; -typedef __int128_t lll; // (can be ll if coords are < 2e4) +using P = Point; +using Q = struct Quad*; +using lll = __int128_t; // (can be ll if coords are < 2e4) P arb(LLONG_MAX,LLONG_MAX); // not equal to any other point struct Quad { diff --git a/content/geometry/HullDiameter.h b/content/geometry/HullDiameter.h index f55958c9e..149e8046f 100644 --- a/content/geometry/HullDiameter.h +++ b/content/geometry/HullDiameter.h @@ -11,7 +11,7 @@ #pragma once #include "Point.h" -typedef Point P; +using P = Point; array hullDiameter(vector

S) { int n = sz(S), j = n < 2 ? 0 : 1; pair> res({0, {S[0], S[0]}}); diff --git a/content/geometry/ManhattanMST.h b/content/geometry/ManhattanMST.h index 6c54d6d2e..764bed55c 100644 --- a/content/geometry/ManhattanMST.h +++ b/content/geometry/ManhattanMST.h @@ -13,7 +13,7 @@ #pragma once #include "Point.h" -typedef Point P; +using P = Point; vector> manhattanMST(vector

ps) { vi id(sz(ps)); iota(all(id), 0); diff --git a/content/geometry/Point.h b/content/geometry/Point.h index 75f0d7ccb..0e901c50a 100644 --- a/content/geometry/Point.h +++ b/content/geometry/Point.h @@ -12,7 +12,7 @@ template int sgn(T x) { return (x > 0) - (x < 0); } template struct Point { - typedef Point P; + using P = Point; T x, y; explicit Point(T x=0, T y=0) : x(x), y(y) {} bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); } diff --git a/content/geometry/Point3D.h b/content/geometry/Point3D.h index e754ca52d..6e9a27983 100644 --- a/content/geometry/Point3D.h +++ b/content/geometry/Point3D.h @@ -11,8 +11,8 @@ #pragma once template struct Point3D { - typedef Point3D P; - typedef const P& R; + using P = Point3D; + using R = const P&; T x, y, z; explicit Point3D(T x=0, T y=0, T z=0) : x(x), y(y), z(z) {} bool operator<(R p) const { diff --git a/content/geometry/PointInsideHull.h b/content/geometry/PointInsideHull.h index ec7698d1a..a5f78a37a 100644 --- a/content/geometry/PointInsideHull.h +++ b/content/geometry/PointInsideHull.h @@ -16,7 +16,7 @@ #include "sideOf.h" #include "OnSegment.h" -typedef Point P; +using P = Point; bool inHull(const vector

& l, P p, bool strict = true) { int a = 1, b = sz(l) - 1, r = !strict; diff --git a/content/geometry/PolygonCenter.h b/content/geometry/PolygonCenter.h index 31ec38a9f..bae680cbb 100644 --- a/content/geometry/PolygonCenter.h +++ b/content/geometry/PolygonCenter.h @@ -11,7 +11,7 @@ #include "Point.h" -typedef Point P; +using P = Point; P polygonCenter(const vector

& v) { P res(0, 0); double A = 0; for (int i = 0, j = sz(v) - 1; i < sz(v); j = i++) { diff --git a/content/geometry/PolygonCut.h b/content/geometry/PolygonCut.h index e056eb786..2d2098b34 100644 --- a/content/geometry/PolygonCut.h +++ b/content/geometry/PolygonCut.h @@ -22,7 +22,7 @@ #include "Point.h" #include "lineIntersection.h" -typedef Point P; +using P = Point; vector

polygonCut(const vector

& poly, P s, P e) { vector

res; rep(i,0,sz(poly)) { diff --git a/content/geometry/PolygonUnion.h b/content/geometry/PolygonUnion.h index 9ce057eca..3047ecf98 100644 --- a/content/geometry/PolygonUnion.h +++ b/content/geometry/PolygonUnion.h @@ -14,7 +14,7 @@ #include "Point.h" #include "sideOf.h" -typedef Point P; +using P = Point; double rat(P a, P b) { return sgn(b.x) ? a.x/b.x : a.y/b.y; } double polyUnion(vector>& poly) { double ret = 0; diff --git a/content/geometry/SegmentDistance.h b/content/geometry/SegmentDistance.h index fa6624787..7b319f86a 100644 --- a/content/geometry/SegmentDistance.h +++ b/content/geometry/SegmentDistance.h @@ -20,7 +20,7 @@ Returns the shortest distance between point p and the line segment from point s #include "Point.h" -typedef Point P; +using P = Point; double segDist(P& s, P& e, P& p) { if (s==e) return (p-s).dist(); auto d = (e-s).dist2(), t = min(d,max(.0,(p-s).dot(e-s))); diff --git a/content/geometry/circumcircle.h b/content/geometry/circumcircle.h index e45f402a8..97a56ffc5 100644 --- a/content/geometry/circumcircle.h +++ b/content/geometry/circumcircle.h @@ -17,7 +17,7 @@ The circumcirle of a triangle is the circle intersecting all three vertices. ccR #include "Point.h" -typedef Point P; +using P = Point; double ccRadius(const P& A, const P& B, const P& C) { return (B-A).dist()*(C-B).dist()*(A-C).dist()/ abs((B-A).cross(C-A))/2; diff --git a/content/geometry/kdTree.h b/content/geometry/kdTree.h index 4c32621d6..b150c77db 100644 --- a/content/geometry/kdTree.h +++ b/content/geometry/kdTree.h @@ -9,8 +9,8 @@ #include "Point.h" -typedef long long T; -typedef Point P; +using T = long long; +using P = Point; const T INF = numeric_limits::max(); bool on_x(const P& a, const P& b) { return a.x < b.x; } diff --git a/content/geometry/linearTransformation.h b/content/geometry/linearTransformation.h index 74f175d8c..b5848ef89 100644 --- a/content/geometry/linearTransformation.h +++ b/content/geometry/linearTransformation.h @@ -18,7 +18,7 @@ #include "Point.h" -typedef Point P; +using P = Point; P linearTransformation(const P& p0, const P& p1, const P& q0, const P& q1, const P& r) { P dp = p1-p0, dq = q1-q0, num(dp.cross(dq), dp.dot(dq)); diff --git a/content/graph/CompressTree.h b/content/graph/CompressTree.h index dddb48f65..fe9adf27d 100644 --- a/content/graph/CompressTree.h +++ b/content/graph/CompressTree.h @@ -14,7 +14,7 @@ #include "LCA.h" -typedef vector> vpi; +using vpi = vector>; vpi compressTree(LCA& lca, const vi& subset) { static vi rev; rev.resize(sz(lca.time)); vi li = subset, &T = lca.time; diff --git a/content/graph/GomoryHu.h b/content/graph/GomoryHu.h index 2ca3c8bb6..6d8d4b003 100644 --- a/content/graph/GomoryHu.h +++ b/content/graph/GomoryHu.h @@ -18,7 +18,7 @@ #include "PushRelabel.h" -typedef array Edge; +using Edge = array; vector gomoryHu(int N, vector ed) { vector tree; vi par(N); diff --git a/content/graph/MaximalCliques.h b/content/graph/MaximalCliques.h index 374ed008f..47ff06441 100644 --- a/content/graph/MaximalCliques.h +++ b/content/graph/MaximalCliques.h @@ -15,7 +15,7 @@ /// degree, where degrees go down as nodes are removed. /// (mostly irrelevant given MaximumClique) -typedef bitset<128> B; +using B = bitset<128>; template void cliques(vector& eds, F f, B P = ~B(), B X={}, B R={}) { if (!P.any()) { if (!X.any()) f(R); return; } diff --git a/content/graph/MaximumClique.h b/content/graph/MaximumClique.h index a579387f5..1eb56a32d 100644 --- a/content/graph/MaximumClique.h +++ b/content/graph/MaximumClique.h @@ -10,11 +10,11 @@ * faster for sparse graphs. * Status: stress-tested */ -typedef vector> vb; +using vb = vector>; struct Maxclique { double limit=0.025, pk=0; struct Vertex { int i, d=0; }; - typedef vector vv; + using vv = vector; vb e; vv V; vector C; diff --git a/content/number-theory/ContinuedFractions.h b/content/number-theory/ContinuedFractions.h index 705c8a66a..9f1a3e20c 100644 --- a/content/number-theory/ContinuedFractions.h +++ b/content/number-theory/ContinuedFractions.h @@ -14,7 +14,7 @@ * Status: stress-tested for n <= 300 */ -typedef double d; // for N ~ 1e7; long double for N ~ 1e9 +using d = double; // for N ~ 1e7; long double for N ~ 1e9 pair approximate(d x, ll N) { ll LP = 0, LQ = 1, P = 1, Q = 0, inf = LLONG_MAX; d y = x; for (;;) { diff --git a/content/number-theory/ModMulLL.h b/content/number-theory/ModMulLL.h index 464fe4d7d..5c82ddb29 100644 --- a/content/number-theory/ModMulLL.h +++ b/content/number-theory/ModMulLL.h @@ -16,7 +16,7 @@ */ #pragma once -typedef unsigned long long ull; +using ull = unsigned long long; ull modmul(ull a, ull b, ull M) { ll ret = a * b - M * ull(1.L / M * a * b); return ret + M * (ret < 0) - M * (ret >= (ll)M); diff --git a/content/number-theory/ModSum.h b/content/number-theory/ModSum.h index 0e181c0c0..b13fdfeb9 100644 --- a/content/number-theory/ModSum.h +++ b/content/number-theory/ModSum.h @@ -12,7 +12,7 @@ */ #pragma once -typedef unsigned long long ull; +using ull = unsigned long long; ull sumsq(ull to) { return to / 2 * ((to-1) | 1); } /// ^ written in a weird way to deal with overflows correctly diff --git a/content/numerical/FastFourierTransform.h b/content/numerical/FastFourierTransform.h index 95b4f7faf..50f4507f6 100644 --- a/content/numerical/FastFourierTransform.h +++ b/content/numerical/FastFourierTransform.h @@ -19,8 +19,8 @@ */ #pragma once -typedef complex C; -typedef vector vd; +using C = complex; +using vd = vector; void fft(vector& a) { int n = sz(a), L = 31 - __builtin_clz(n); static vector> R(2, 1); diff --git a/content/numerical/FastFourierTransformMod.h b/content/numerical/FastFourierTransformMod.h index 0208a85dd..d786d6311 100644 --- a/content/numerical/FastFourierTransformMod.h +++ b/content/numerical/FastFourierTransformMod.h @@ -15,7 +15,7 @@ #include "FastFourierTransform.h" -typedef vector vl; +using vl = vector; template vl convMod(const vl &a, const vl &b) { if (a.empty() || b.empty()) return {}; vl res(sz(a) + sz(b) - 1); diff --git a/content/numerical/HillClimbing.h b/content/numerical/HillClimbing.h index 7202a42c4..e70ac616f 100644 --- a/content/numerical/HillClimbing.h +++ b/content/numerical/HillClimbing.h @@ -8,7 +8,7 @@ */ #pragma once -typedef array P; +using P = array; template pair hillClimb(P start, F f) { pair cur(f(start), start); diff --git a/content/numerical/IntegrateAdaptive.h b/content/numerical/IntegrateAdaptive.h index ea90bc1e1..b63186d23 100644 --- a/content/numerical/IntegrateAdaptive.h +++ b/content/numerical/IntegrateAdaptive.h @@ -13,7 +13,7 @@ */ #pragma once -typedef double d; +using d = double; #define S(a,b) (f(a) + 4*f((a+b) / 2) + f(b)) * (b-a) / 6 template diff --git a/content/numerical/LinearRecurrence.h b/content/numerical/LinearRecurrence.h index b5ee365eb..62e975eae 100644 --- a/content/numerical/LinearRecurrence.h +++ b/content/numerical/LinearRecurrence.h @@ -16,7 +16,7 @@ const ll mod = 5; /** exclude-line */ -typedef vector Poly; +using Poly = vector; ll linearRec(Poly S, Poly tr, ll k) { int n = sz(tr); diff --git a/content/numerical/NumberTheoreticTransform.h b/content/numerical/NumberTheoreticTransform.h index e59ba7e8a..c9a986bb5 100644 --- a/content/numerical/NumberTheoreticTransform.h +++ b/content/numerical/NumberTheoreticTransform.h @@ -21,7 +21,7 @@ const ll mod = (119 << 23) + 1, root = 62; // = 998244353 // For p < 2^30 there is also e.g. 5 << 25, 7 << 26, 479 << 21 // and 483 << 21 (same root). The last two are > 10^9. -typedef vector vl; +using vl = vector; void ntt(vl &a) { int n = sz(a), L = 31 - __builtin_clz(n); static vl rt(2, 1); diff --git a/content/numerical/PolyInterpolate.h b/content/numerical/PolyInterpolate.h index 9343edbc3..694f0bd3b 100644 --- a/content/numerical/PolyInterpolate.h +++ b/content/numerical/PolyInterpolate.h @@ -10,7 +10,7 @@ */ #pragma once -typedef vector vd; +using vd = vector; vd interpolate(vd x, vd y, int n) { vd res(n), temp(n); rep(k,0,n-1) rep(i,k+1,n) diff --git a/content/numerical/Simplex.h b/content/numerical/Simplex.h index 090026c8e..6963111f8 100644 --- a/content/numerical/Simplex.h +++ b/content/numerical/Simplex.h @@ -15,9 +15,9 @@ */ #pragma once -typedef double T; // long double, Rational, double + mod

... -typedef vector vd; -typedef vector vvd; +using T = double; // long double, Rational, double + mod

... +using vd = vector; +using vvd = vector; const T eps = 1e-8, inf = 1/.0; #define MP make_pair diff --git a/content/numerical/SolveLinear.h b/content/numerical/SolveLinear.h index 318e0c977..add444ccb 100644 --- a/content/numerical/SolveLinear.h +++ b/content/numerical/SolveLinear.h @@ -9,7 +9,7 @@ */ #pragma once -typedef vector vd; +using vd = vector; const double eps = 1e-12; int solveLinear(vector& A, vd& b, vd& x) { diff --git a/content/numerical/SolveLinearBinary.h b/content/numerical/SolveLinearBinary.h index 710878914..cbf81a666 100644 --- a/content/numerical/SolveLinearBinary.h +++ b/content/numerical/SolveLinearBinary.h @@ -10,7 +10,7 @@ */ #pragma once -typedef bitset<1000> bs; +using bs = bitset<1000>; int solveLinear(vector& A, vi& b, bs& x, int m) { int n = sz(A), rank = 0, br; diff --git a/content/numerical/Tridiagonal.h b/content/numerical/Tridiagonal.h index 5c34e7a26..632945293 100644 --- a/content/numerical/Tridiagonal.h +++ b/content/numerical/Tridiagonal.h @@ -33,7 +33,7 @@ the algorithm is numerically stable and neither \texttt{tr} nor the check for \t */ #pragma once -typedef double T; +using T = double; vector tridiagonal(vector diag, const vector& super, const vector& sub, vector b) { int n = sz(b); vi tr(n); diff --git a/content/strings/Hashing-codeforces.h b/content/strings/Hashing-codeforces.h index 5129112db..293a6106a 100644 --- a/content/strings/Hashing-codeforces.h +++ b/content/strings/Hashing-codeforces.h @@ -9,11 +9,11 @@ */ #pragma once -typedef uint64_t ull; +using ull = uint64_t; static int C; // initialized below // Arithmetic mod two primes and 2^32 simultaneously. -// "typedef uint64_t H;" instead if Thue-Morse does not apply. +// "using H = uint64_t;" instead if Thue-Morse does not apply. template struct A { int x; B b; A(int x=0) : x(x), b(x) {} @@ -25,7 +25,7 @@ struct A { bool operator==(A o) const { return (ull)*this == (ull)o; } bool operator<(A o) const { return (ull)*this < (ull)o; } }; -typedef A<1000000007, A<1000000009, unsigned>> H; +using H = A<1000000007, A<1000000009, unsigned>>; struct HashInterval { vector ha, pw; diff --git a/content/strings/Hashing.h b/content/strings/Hashing.h index 62cefcb79..6a80b41ae 100644 --- a/content/strings/Hashing.h +++ b/content/strings/Hashing.h @@ -11,9 +11,9 @@ // Arithmetic mod 2^64-1. 2x slower than mod 2^64 and more // code, but works on evil test data (e.g. Thue-Morse, where // ABBA... and BAAB... of length 2^10 hash the same mod 2^64). -// "typedef ull H;" instead if you think test data is random, +// "using H = ull;" instead if you think test data is random, // or work mod 10^9+7 if the Birthday paradox is not a problem. -typedef uint64_t ull; +using ull = uint64_t; struct H { ull x; H(ull x=0) : x(x) {} H operator+(H o) { return x + o.x + (x + o.x < x); } diff --git a/content/various/BumpAllocatorSTL.h b/content/various/BumpAllocatorSTL.h index 3cb615fcb..d75cad5b7 100644 --- a/content/various/BumpAllocatorSTL.h +++ b/content/various/BumpAllocatorSTL.h @@ -13,7 +13,7 @@ char buf[450 << 20] alignas(16); size_t buf_ind = sizeof buf; template struct small { - typedef T value_type; + using value_type = T; small() {} template small(const U&) {} T* allocate(size_t n) { diff --git a/content/various/FastMod.h b/content/various/FastMod.h index 78adedaf9..b1527451b 100644 --- a/content/various/FastMod.h +++ b/content/various/FastMod.h @@ -13,7 +13,7 @@ */ #pragma once -typedef unsigned long long ull; +using ull = unsigned long long; struct FastMod { ull b, m; FastMod(ull b) : b(b), m(-1ULL / b) {} diff --git a/content/various/LIS.h b/content/various/LIS.h index 51b8805ba..50b856382 100644 --- a/content/various/LIS.h +++ b/content/various/LIS.h @@ -10,7 +10,7 @@ template vi lis(const vector& S) { if (S.empty()) return {}; vi prev(sz(S)); - typedef pair p; + using p = pair; vector

res; rep(i,0,sz(S)) { // change 0 -> i for longest non-decreasing subsequence diff --git a/content/various/SIMD.h b/content/various/SIMD.h index 0761b1348..fb2d5b6c6 100644 --- a/content/various/SIMD.h +++ b/content/various/SIMD.h @@ -15,7 +15,7 @@ #pragma GCC target ("avx2") // or sse4.1 #include "immintrin.h" /** keep-include */ -typedef __m256i mi; +using mi = __m256i; #define L(x) _mm256_loadu_si256((mi*)&(x)) // High-level/specific methods: diff --git a/doc/modmul-proof.md b/doc/modmul-proof.md index 5c173f341..76fb50514 100644 --- a/doc/modmul-proof.md +++ b/doc/modmul-proof.md @@ -1,9 +1,9 @@ Proof for why the following: ```cpp -typedef uint64_t u64; -typedef int64_t i64; -typedef long double ld; +using u64 = uint64_t; +using i64 = int64_t; +using ld = long double; u64 modmul(u64 a, u64 b, u64 c) { i64 ret = a * b - c * u64(ld(a) * ld(b) / ld(c)); diff --git a/doc/modmul-proof.tex b/doc/modmul-proof.tex index bf7afc32c..c59d1ac01 100644 --- a/doc/modmul-proof.tex +++ b/doc/modmul-proof.tex @@ -20,8 +20,8 @@ \section{Introduction} Within computational number theory, and for hashing, there is sometimes a need to compute modular multiplications $a \cdot b \pmod{c}$ for relatively large $c$, in particular larger than $2^{32}$. KACTL contains the following algorithm for computing this for $0 \le a, b \le c < 7.268\cdot 10^{18}$: \footnote{this number equals $r \cdot 2^{64}$, where $r = (\sqrt{177} - 7) / 16 \approx 0.394$ is the positive solution to the equation $8x^2 + 7x = 4$.} \begin{lstlisting}[language=C++] -typedef int64_t ll; -typedef uint64_t ull; +using ll = int64_t; +using ull = uint64_t; ull mod_mul(ull a, ull b, ull c) { ll ret = a * b - c * ull(1.L / c * a * b); return ret + c * (ret < 0) - c * (ret >= (ll)c); diff --git a/old-unit-tests/data structures/test_intervalUnion.cpp b/old-unit-tests/data structures/test_intervalUnion.cpp index 4a4f5cbe2..f7af2ea13 100644 --- a/old-unit-tests/data structures/test_intervalUnion.cpp +++ b/old-unit-tests/data structures/test_intervalUnion.cpp @@ -3,7 +3,7 @@ #include #include -typedef vector vpii; +using vpii = vector; class test_intervalUnion : public UnitTest diff --git a/old-unit-tests/data structures/test_unionFind.cpp b/old-unit-tests/data structures/test_unionFind.cpp index 60e010fa9..94e9b991c 100644 --- a/old-unit-tests/data structures/test_unionFind.cpp +++ b/old-unit-tests/data structures/test_unionFind.cpp @@ -3,7 +3,7 @@ #include #include -typedef vector vpii; +using vpii = vector; class test_union_find : public UnitTest diff --git a/old-unit-tests/geometry/test_circleTangents.cpp b/old-unit-tests/geometry/test_circleTangents.cpp index 2b46823db..691c5d8be 100644 --- a/old-unit-tests/geometry/test_circleTangents.cpp +++ b/old-unit-tests/geometry/test_circleTangents.cpp @@ -12,7 +12,7 @@ class test_circleTangents : virtual ~test_circleTangents() { } virtual void run(int subcase) { - typedef Point P; + using P = Point; pair p = circleTangents(P(100,1),P(0,0),1); cout << p.first << p.second << endl; p = circleTangents(P(104,106),P(100,100),1); diff --git a/old-unit-tests/geometry/test_circumcircle.cpp b/old-unit-tests/geometry/test_circumcircle.cpp index e3aea9098..511e4628a 100644 --- a/old-unit-tests/geometry/test_circumcircle.cpp +++ b/old-unit-tests/geometry/test_circumcircle.cpp @@ -7,7 +7,7 @@ class test_circumcircle : public UnitTest { public: - typedef Point P; + using P = Point; test_circumcircle() : UnitTest("test_circumcircle") { } virtual ~test_circumcircle() { } diff --git a/old-unit-tests/geometry/test_convexHull.cpp b/old-unit-tests/geometry/test_convexHull.cpp index 2babc9b52..125fcb94d 100644 --- a/old-unit-tests/geometry/test_convexHull.cpp +++ b/old-unit-tests/geometry/test_convexHull.cpp @@ -2,7 +2,7 @@ #include "../../content/geometry/convexHull.h" #include #include -typedef Point P; +using P = Point; template ostream & operator<<(ostream & os, const vector p) { @@ -60,7 +60,7 @@ class test_convexHull : public UnitTest { void test(int subcase) { run(subcase); - typedef Point P; + using P = Point; P p1[3] = {P(1,1),P(3,2),P(1,5)}; check(convexHull(p1,p1+3),p1+3); diff --git a/old-unit-tests/geometry/test_lineDistDouble.cpp b/old-unit-tests/geometry/test_lineDistDouble.cpp index bd19dd2cb..3ea624e7c 100644 --- a/old-unit-tests/geometry/test_lineDistDouble.cpp +++ b/old-unit-tests/geometry/test_lineDistDouble.cpp @@ -59,7 +59,7 @@ class test_lineDistDouble : test(p2-p2,p1-p2,p3-p2,-a); test(p1+p3,p2+p3,p3+p3,a); test(p2.perp()*-1,p1.perp()*-1,p3.perp()*-1,-a); - typedef Point3D P3; + using P3 = Point3D; test(P3(p1.x,p1.y,3.0),P3(p2.x,p2.y,3.0),P3(p3.x,p3.y,3.0),abs(a)); test(P3(p1.x,p1.y,1.0),P3(p2.x,p2.y,1.0),P3(p3.x,p3.y,3.0),sqrt(a*a+4)); test(P3(p1.x,8.2,p1.y),P3(p2.x,8.2,p2.y),P3(p3.x,6.2,p3.y),sqrt(a*a+4)); diff --git a/old-unit-tests/geometry/test_lineIntersection.cpp b/old-unit-tests/geometry/test_lineIntersection.cpp index c94f1f2dc..af1ce9efb 100644 --- a/old-unit-tests/geometry/test_lineIntersection.cpp +++ b/old-unit-tests/geometry/test_lineIntersection.cpp @@ -12,7 +12,7 @@ class test_lineIntersection : virtual ~test_lineIntersection() { } virtual void run(int subcase) { - typedef Point P; + using P = Point; P r; check(lineIntersection(P(0,0),P(1,0),P(0,2),P(1,1),r),1); if (!(r==P(2,0))) diff --git a/old-unit-tests/geometry/test_linearTransformation.cpp b/old-unit-tests/geometry/test_linearTransformation.cpp index db33c3d5c..9ae321169 100644 --- a/old-unit-tests/geometry/test_linearTransformation.cpp +++ b/old-unit-tests/geometry/test_linearTransformation.cpp @@ -12,7 +12,7 @@ class test_linearTransformation : virtual ~test_linearTransformation() { } virtual void run(int subcase) { - typedef Point P; + using P = Point; check(linearTransformation(P(0,0),P(1,0),P(1,1),P(1,2),P(2,1)),P(0,3)); check(linearTransformation(P(1,1),P(5,4),P(2,-1),P(4,-3),P(8,0)),P(2,-5)); } diff --git a/old-unit-tests/geometry/test_polygonArea.cpp b/old-unit-tests/geometry/test_polygonArea.cpp index 426b3f74f..abb30216f 100644 --- a/old-unit-tests/geometry/test_polygonArea.cpp +++ b/old-unit-tests/geometry/test_polygonArea.cpp @@ -12,7 +12,7 @@ class test_polygonArea : virtual ~test_polygonArea() { } virtual void run(int subcase) { - typedef Point P; + using P = Point; vector

p; p.push_back(P(0,-2)); p.push_back(P(1,-1)); diff --git a/old-unit-tests/geometry/test_polygonCenter.cpp b/old-unit-tests/geometry/test_polygonCenter.cpp index 6a946888d..174cff0fc 100644 --- a/old-unit-tests/geometry/test_polygonCenter.cpp +++ b/old-unit-tests/geometry/test_polygonCenter.cpp @@ -12,7 +12,7 @@ class test_polygonCenter : virtual ~test_polygonCenter() { } virtual void run(int subcase) { - typedef Point P; + using P = Point; if (subcase == 0) { P p[] = {P(0,0),P(3,0),P(0,3)}; check(polygonCenter(p,p+3),P(1,1)); diff --git a/old-unit-tests/geometry/test_polygonCut.cpp b/old-unit-tests/geometry/test_polygonCut.cpp index 159d751d5..7b90a5d23 100644 --- a/old-unit-tests/geometry/test_polygonCut.cpp +++ b/old-unit-tests/geometry/test_polygonCut.cpp @@ -3,7 +3,7 @@ #include #include -typedef Point P; +using P = Point; class test_polygonCut : public UnitTest { diff --git a/old-unit-tests/geometry/test_sideOf.cpp b/old-unit-tests/geometry/test_sideOf.cpp index c3fb1f3a9..ae606c2fb 100644 --- a/old-unit-tests/geometry/test_sideOf.cpp +++ b/old-unit-tests/geometry/test_sideOf.cpp @@ -12,7 +12,7 @@ class test_sideOf : virtual ~test_sideOf() { } virtual void run(int subcase) { - typedef Point P; + using P = Point; check(sideOf(P(0,0),P(1,0),P(1,1)),1); check(sideOf(P(0,0),P(1,0),P(1,0)),0); check(sideOf(P(0,0),P(1,0),P(1,-1)),-1); diff --git a/old-unit-tests/global.h b/old-unit-tests/global.h index b754442bc..fec32c6a5 100644 --- a/old-unit-tests/global.h +++ b/old-unit-tests/global.h @@ -10,6 +10,6 @@ using namespace std; #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() -typedef long long ll; -typedef pair pii; -typedef vector vi; +using ll = long long; +using pii = pair; +using vi = vector; diff --git a/stress-tests/data-structures/SegmentTree.cpp b/stress-tests/data-structures/SegmentTree.cpp index d3b19c8a3..61d605af4 100644 --- a/stress-tests/data-structures/SegmentTree.cpp +++ b/stress-tests/data-structures/SegmentTree.cpp @@ -26,7 +26,7 @@ const int lut[6][6] = { }; struct Tree { - typedef int T; + using T = int; const T unit = 0; T f(T a, T b) { return lut[a][b]; } vector s; int n; diff --git a/stress-tests/geometry/CircleLine.cpp b/stress-tests/geometry/CircleLine.cpp index cfe9d8609..687058b70 100644 --- a/stress-tests/geometry/CircleLine.cpp +++ b/stress-tests/geometry/CircleLine.cpp @@ -4,7 +4,7 @@ #include "../../content/geometry/lineDistance.h" #include "../../content/geometry/CircleLine.h" -typedef Point P; +using P = Point; int main() { { auto res = circleLine(P(0, 0), 1, P(-1, -1), P(1, 1)); diff --git a/stress-tests/geometry/CirclePolygon.cpp b/stress-tests/geometry/CirclePolygon.cpp index c03ed33ea..cf54e73fc 100644 --- a/stress-tests/geometry/CirclePolygon.cpp +++ b/stress-tests/geometry/CirclePolygon.cpp @@ -4,7 +4,7 @@ #include "../utilities/genPolygon.h" namespace orig{ -typedef Point P; +using P = Point; long double areaCT(P pa, P pb, long double r) { if (pa.dist() < pb.dist()) swap(pa, pb); if (sgn(pb.dist()) == 0) return 0; diff --git a/stress-tests/geometry/CircleTangents.cpp b/stress-tests/geometry/CircleTangents.cpp index 1ca4ef32b..496b8adc0 100644 --- a/stress-tests/geometry/CircleTangents.cpp +++ b/stress-tests/geometry/CircleTangents.cpp @@ -4,7 +4,7 @@ #include "../../content/geometry/lineDistance.h" #include "../utilities/randGeo.h" -typedef Point P; +using P = Point; signed main() { for (int i = 0; i < 1000000; i++) { diff --git a/stress-tests/geometry/ClosestPair.cpp b/stress-tests/geometry/ClosestPair.cpp index 6d4186adc..1ac9b13de 100644 --- a/stress-tests/geometry/ClosestPair.cpp +++ b/stress-tests/geometry/ClosestPair.cpp @@ -10,7 +10,7 @@ bool y_it_less(const It& i,const It& j) {return i->y < j->y;} template /* IIt = vector::iterator */ double cp_sub(IIt ya, IIt yaend, IIt xa, It &i1, It &i2) { - typedef typename iterator_traits::value_type P; + using P = typename iterator_traits::value_type; int n = yaend-ya, split = n/2; if(n <= 3) { // base case double a = (*xa[1]-*xa[0]).dist(), b = 1e50, c = 1e50; diff --git a/stress-tests/geometry/DelaunayTriangulation.cpp b/stress-tests/geometry/DelaunayTriangulation.cpp index cd72a1a2f..933e30f65 100644 --- a/stress-tests/geometry/DelaunayTriangulation.cpp +++ b/stress-tests/geometry/DelaunayTriangulation.cpp @@ -7,7 +7,7 @@ #include "../../content/geometry/PolygonArea.h" #include "../../content/geometry/circumcircle.h" -typedef Point P; +using P = Point; int main() { feenableexcept(29); rep(it,0,100000) {{ diff --git a/stress-tests/geometry/LineHullIntersection.cpp b/stress-tests/geometry/LineHullIntersection.cpp index a7e8d0ed2..fada7d775 100644 --- a/stress-tests/geometry/LineHullIntersection.cpp +++ b/stress-tests/geometry/LineHullIntersection.cpp @@ -4,8 +4,8 @@ template<> struct Point { - typedef Point P; - typedef double T; + using P = Point; + using T = double; T x, y; explicit Point(T x=0, T y=0) : x(x), y(y) {} Point(const Point& other) : x((double)other.x), y((double)other.y) {} @@ -58,7 +58,7 @@ int segmentIntersection(const P& s1, const P& e1, if (a < 0) { a = -a; a1 = -a1; a2 = -a2; } if (0 PD; + using PD = Point; r1 = PD(s1) - PD(v1*a2)/(double)a; return 1; } diff --git a/stress-tests/geometry/LineProjectionReflection.cpp b/stress-tests/geometry/LineProjectionReflection.cpp index 187df8e56..fa1b591f4 100644 --- a/stress-tests/geometry/LineProjectionReflection.cpp +++ b/stress-tests/geometry/LineProjectionReflection.cpp @@ -3,7 +3,7 @@ #include "../../content/geometry/LineProjectionReflection.h" #include "../../content/geometry/lineDistance.h" -typedef Point P; +using P = Point; int main() { cin.sync_with_stdio(0); cin.tie(0); diff --git a/stress-tests/geometry/ManhattanMST.cpp b/stress-tests/geometry/ManhattanMST.cpp index fde65282d..6cd718516 100644 --- a/stress-tests/geometry/ManhattanMST.cpp +++ b/stress-tests/geometry/ManhattanMST.cpp @@ -5,8 +5,8 @@ #include "../../content/data-structures/UnionFind.h" -typedef Point P; -typedef int T; +using P = Point; +using T = int; T rectilinear_mst_n(vector

ps) { struct edge { int src, dst; T weight; }; vector edges; diff --git a/stress-tests/geometry/PolygonArea.cpp b/stress-tests/geometry/PolygonArea.cpp index 2186866bf..3d11613b6 100644 --- a/stress-tests/geometry/PolygonArea.cpp +++ b/stress-tests/geometry/PolygonArea.cpp @@ -6,7 +6,7 @@ int main() { srand(0); - typedef Point P; + using P = Point; vector

ps = {P{0,0}, P{6,4}, P{0,9}}; int count = 0; P su{0,0}; diff --git a/stress-tests/geometry/PolygonCut.cpp b/stress-tests/geometry/PolygonCut.cpp index 7d5b37dd9..173d2a46c 100644 --- a/stress-tests/geometry/PolygonCut.cpp +++ b/stress-tests/geometry/PolygonCut.cpp @@ -6,7 +6,7 @@ #include "../../content/geometry/InsidePolygon.h" #include "../../content/geometry/SegmentIntersection.h" -typedef Point P; +using P = Point; int main() { rep(it,0,500) { int N = rand() % 10 + 3; diff --git a/stress-tests/geometry/PolygonUnion.cpp b/stress-tests/geometry/PolygonUnion.cpp index d174a6821..494b3d1a7 100644 --- a/stress-tests/geometry/PolygonUnion.cpp +++ b/stress-tests/geometry/PolygonUnion.cpp @@ -1,15 +1,15 @@ #include #define all(x) begin(x), end(x) -typedef long long ll; +using ll = long long; using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() -typedef long long ll; -typedef pair pii; -typedef vector vi; +using ll = long long; +using pii = pair; +using vi = vector; #include "../../content/geometry/Point.h" #include "../../content/geometry/sideOf.h" @@ -107,11 +107,11 @@ namespace lovelive { #define pb push_back #define fir first #define sec second -typedef double db; +using db = double; const db pi = acos(db(-1)); inline int sgn(db x) { return (x > 1e-8) - (x < -1e-8); } -typedef complex cpoi; +using cpoi = complex; db polygon_union(vector py[], int n) { auto ratio = [](cpoi &a, cpoi &b, cpoi &c) { cpoi x = b - a, y = c - a; diff --git a/stress-tests/geometry/SegmentIntersection.cpp b/stress-tests/geometry/SegmentIntersection.cpp index e2e65b504..0280d092b 100644 --- a/stress-tests/geometry/SegmentIntersection.cpp +++ b/stress-tests/geometry/SegmentIntersection.cpp @@ -31,7 +31,7 @@ int segmentIntersection(const P& s1, const P& e1, return 1; } } -typedef Point P; +using P = Point; bool eq(P a, P b) { return (a-b).dist()<1e-8; } diff --git a/stress-tests/geometry/insidePolygon.cpp b/stress-tests/geometry/insidePolygon.cpp index 32e006acc..a5fd8e521 100644 --- a/stress-tests/geometry/insidePolygon.cpp +++ b/stress-tests/geometry/insidePolygon.cpp @@ -5,9 +5,9 @@ using namespace std; #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() -typedef long long ll; -typedef pair pii; -typedef vector vi; +using ll = long long; +using pii = pair; +using vi = vector; const double EPS =1e-8; @@ -33,7 +33,7 @@ bool insidePolygon(It begin, It end, const P& p, return n&1; //inside if odd number of intersections } } -typedef Point P; +using P = Point; bool eq(P a, P b) { return (a-b).dist() vpi; -typedef vector graph; +using vpi = vector; +using graph = vector; struct LCA { vi time; diff --git a/stress-tests/graph/MinCostMaxFlow.cpp b/stress-tests/graph/MinCostMaxFlow.cpp index 17c96426b..3c3110a7f 100644 --- a/stress-tests/graph/MinCostMaxFlow.cpp +++ b/stress-tests/graph/MinCostMaxFlow.cpp @@ -26,7 +26,7 @@ struct MCMF2 { void setpi(int s) {} }; -// typedef MCMF2 MCMF; +// using MCMF = MCMF2; #if 1 static size_t i; @@ -40,7 +40,7 @@ void* operator new(size_t s) { void operator delete(void*) noexcept {} #endif -typedef vector vd; +using vd = vector; bool zero(ll x) { return x == 0; } ll MinCostMatching(const vector& cost, vi& L, vi& R) { int n = sz(cost), mated = 0; diff --git a/stress-tests/graph/MinCostMaxFlow2.h b/stress-tests/graph/MinCostMaxFlow2.h index eb67ed9cf..4a0485741 100644 --- a/stress-tests/graph/MinCostMaxFlow2.h +++ b/stress-tests/graph/MinCostMaxFlow2.h @@ -7,7 +7,7 @@ */ #pragma once -typedef int Flow; +using Flow = int; Flow inf = 1<<28; struct FlowEdge { diff --git a/stress-tests/graph/oldHLD.h b/stress-tests/graph/oldHLD.h index e633a2a0a..a276dd926 100644 --- a/stress-tests/graph/oldHLD.h +++ b/stress-tests/graph/oldHLD.h @@ -1,7 +1,7 @@ #include "../../content/data-structures/SegmentTree.h" -typedef vector vpi; +using vpi = vector; struct Node { int d, par, val, chain = -1, pos = -1; @@ -14,7 +14,7 @@ struct Chain { }; struct HLD { - typedef int T; + using T = int; const T LOW = -(1<<29); void f(T& a, T b) { a = max(a, b); } diff --git a/stress-tests/numerical/IntDeterminant.cpp b/stress-tests/numerical/IntDeterminant.cpp index b85e2147d..83a185cba 100644 --- a/stress-tests/numerical/IntDeterminant.cpp +++ b/stress-tests/numerical/IntDeterminant.cpp @@ -2,7 +2,7 @@ const int mod = 7; // 4 -typedef vector> vvll; +using vvll = vector>; ll det(vvll& a) { // integer determinant int n = sz(a); ll ans = 1; rep(i,0,n) { diff --git a/stress-tests/numerical/NumberTheoreticTransform.cpp b/stress-tests/numerical/NumberTheoreticTransform.cpp index 22d7d24e5..34ff19966 100644 --- a/stress-tests/numerical/NumberTheoreticTransform.cpp +++ b/stress-tests/numerical/NumberTheoreticTransform.cpp @@ -1,6 +1,6 @@ #include "../utilities/template.h" -typedef vector vl; +using vl = vector; namespace ignore { #include "../../content/number-theory/ModPow.h" } diff --git a/stress-tests/numerical/SolveLinear.cpp b/stress-tests/numerical/SolveLinear.cpp index f4475f72e..756e4368b 100644 --- a/stress-tests/numerical/SolveLinear.cpp +++ b/stress-tests/numerical/SolveLinear.cpp @@ -11,7 +11,7 @@ int modinv(int x) { // return lut[x+4]; } -typedef vector vd; +using vd = vector; int solveLinear(vector& A, vd& b, vd& x) { int n = sz(A), m = sz(x), rank = 0, br, bc; diff --git a/stress-tests/numerical/SolveLinear2.cpp b/stress-tests/numerical/SolveLinear2.cpp index 05ebbdd9f..deea9fbfc 100644 --- a/stress-tests/numerical/SolveLinear2.cpp +++ b/stress-tests/numerical/SolveLinear2.cpp @@ -1,6 +1,6 @@ #include "../utilities/template.h" -typedef vector vd; +using vd = vector; const double eps = 1e-12; enum { YES, NO, MULT }; diff --git a/stress-tests/numerical/SolveLinearBinary.cpp b/stress-tests/numerical/SolveLinearBinary.cpp index ae11928aa..d0282d94b 100644 --- a/stress-tests/numerical/SolveLinearBinary.cpp +++ b/stress-tests/numerical/SolveLinearBinary.cpp @@ -2,7 +2,7 @@ const int nmax = 5, mmax = 5, nmmax = 16; -typedef bitset<5> bs; +using bs = bitset<5>; int solveLinear(vector& A, vi& b, bs& x, int m) { int n = sz(A), rank = 0, br; diff --git a/stress-tests/numerical/Tridiagonal.cpp b/stress-tests/numerical/Tridiagonal.cpp index 92a3ff414..a94e703d6 100644 --- a/stress-tests/numerical/Tridiagonal.cpp +++ b/stress-tests/numerical/Tridiagonal.cpp @@ -54,7 +54,7 @@ int modinv(int x) { return inv[x]; } -typedef vector vd; +using vd = vector; int solveLinear(vector& A, vd& b, vd& x) { int n = sz(A), m = sz(x), rank = 0, br, bc; @@ -178,7 +178,7 @@ fail:; namespace real { -typedef double T; +using T = double; vector tridiagonal(vector diag, const vector& super, const vector& sub, vector b) { int n = sz(b); vi tr(n); @@ -206,8 +206,8 @@ vector tridiagonal(vector diag, const vector& super, return b; } -typedef double T; -typedef vector vd; +using T = double; +using vd = vector; int solveLinear(vector& A, vd& b, vd& x) { int n = sz(A), m = sz(x), rank = 0, br, bc; diff --git a/stress-tests/strings/SuffixArray.cpp b/stress-tests/strings/SuffixArray.cpp index d4a9ee521..888f3fb31 100644 --- a/stress-tests/strings/SuffixArray.cpp +++ b/stress-tests/strings/SuffixArray.cpp @@ -81,8 +81,8 @@ void test(const string& s, int alpha) { const int MAXN = 1e5; namespace old { -typedef long long ll; -typedef pair pli; +using ll = long long; +using pli = pair; void count_sort(vector &b, int bits) { // (optional) // this is just 3 times faster than stl sort for N=10^6 int mask = (1 << bits) - 1; diff --git a/stress-tests/utilities/template.h b/stress-tests/utilities/template.h index eb14ea010..876a033ba 100644 --- a/stress-tests/utilities/template.h +++ b/stress-tests/utilities/template.h @@ -4,6 +4,6 @@ using namespace std; #define rep(i, from, to) for (int i = from; i < (to); ++i) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() -typedef long long ll; -typedef pair pii; -typedef vector vi; +using ll = long long; +using pii = pair; +using vi = vector; diff --git a/stress-tests/various/FastMod.cpp b/stress-tests/various/FastMod.cpp index b6f829dab..9ee6b8127 100644 --- a/stress-tests/various/FastMod.cpp +++ b/stress-tests/various/FastMod.cpp @@ -2,7 +2,7 @@ #include "../../content/various/FastMod.h" -typedef unsigned long long ull; +using ull = unsigned long long; struct OldBarrett { ull b, m; OldBarrett(ull b) : b(b), m(-1ULL / b) {} diff --git a/stress-tests/various/LIS.cpp b/stress-tests/various/LIS.cpp index a75ce4cdb..f132def20 100644 --- a/stress-tests/various/LIS.cpp +++ b/stress-tests/various/LIS.cpp @@ -5,7 +5,7 @@ template vi lisWeak(const vector& S) { if (S.empty()) return {}; vi prev(sz(S)); - typedef pair p; + using p = pair; vector

res; rep(i,0,sz(S)) { // 0 -> i for longest non-decreasing subsequence