Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace typedefs with using #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/contest/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, int> pii;
typedef vector<int> vi;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
cin.tie(0)->sync_with_stdio(0);
Expand Down
2 changes: 1 addition & 1 deletion content/data-structures/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#pragma once

template<class T, int N> struct Matrix {
typedef Matrix M;
using M = Matrix;
array<array<T, N>, N> d{};
M operator*(const M& m) const {
M a;
Expand Down
2 changes: 1 addition & 1 deletion content/data-structures/SegmentTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> s; int n;
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/3dHull.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "Point3D.h"

typedef Point3D<double> P3;
using P3 = Point3D<double>;

struct PR {
void ins(int x) { (a == -1 ? a : b) = x; }
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/CircleIntersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "Point.h"

typedef Point<double> P;
using P = Point<double>;
bool circleInter(P a,P b,double r1,double r2,pair<P, P>* out) {
if (a == b) { assert(r1 != r2); return false; }
P vec = b - a;
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/CirclePolygonIntersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "../../content/geometry/Point.h"

typedef Point<double> P;
using P = Point<double>;
#define arg(p, q) atan2(p.cross(q), p.dot(q))
double circlePoly(P c, double r, vector<P> ps) {
auto tri = [&](P p, P q) {
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/ClosestPair.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "Point.h"

typedef Point<ll> P;
using P = Point<ll>;
pair<P, P> closest(vector<P> v) {
assert(sz(v) > 1);
set<P> S;
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/ConvexHull.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Points on the edge of the hull between two other points are not considered part

#include "Point.h"

typedef Point<ll> P;
using P = Point<ll>;
vector<P> convexHull(vector<P> pts) {
if (sz(pts) <= 1) return pts;
sort(all(pts));
Expand Down
6 changes: 3 additions & 3 deletions content/geometry/FastDelaunay.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include "Point.h"

typedef Point<ll> P;
typedef struct Quad* Q;
typedef __int128_t lll; // (can be ll if coords are < 2e4)
using P = Point<ll>;
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 {
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/HullDiameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#pragma once
#include "Point.h"

typedef Point<ll> P;
using P = Point<ll>;
array<P, 2> hullDiameter(vector<P> S) {
int n = sz(S), j = n < 2 ? 0 : 1;
pair<ll, array<P, 2>> res({0, {S[0], S[0]}});
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/ManhattanMST.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#pragma once
#include "Point.h"

typedef Point<int> P;
using P = Point<int>;
vector<array<int, 3>> manhattanMST(vector<P> ps) {
vi id(sz(ps));
iota(all(id), 0);
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/Point.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
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); }
Expand Down
4 changes: 2 additions & 2 deletions content/geometry/Point3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#pragma once

template<class T> 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 {
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PointInsideHull.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "sideOf.h"
#include "OnSegment.h"

typedef Point<ll> P;
using P = Point<ll>;

bool inHull(const vector<P>& l, P p, bool strict = true) {
int a = 1, b = sz(l) - 1, r = !strict;
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PolygonCenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "Point.h"

typedef Point<double> P;
using P = Point<double>;
P polygonCenter(const vector<P>& v) {
P res(0, 0); double A = 0;
for (int i = 0, j = sz(v) - 1; i < sz(v); j = i++) {
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PolygonCut.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "Point.h"
#include "lineIntersection.h"

typedef Point<double> P;
using P = Point<double>;
vector<P> polygonCut(const vector<P>& poly, P s, P e) {
vector<P> res;
rep(i,0,sz(poly)) {
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PolygonUnion.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Point.h"
#include "sideOf.h"

typedef Point<double> P;
using P = Point<double>;
double rat(P a, P b) { return sgn(b.x) ? a.x/b.x : a.y/b.y; }
double polyUnion(vector<vector<P>>& poly) {
double ret = 0;
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/SegmentDistance.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Returns the shortest distance between point p and the line segment from point s

#include "Point.h"

typedef Point<double> P;
using P = Point<double>;
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)));
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/circumcircle.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The circumcirle of a triangle is the circle intersecting all three vertices. ccR

#include "Point.h"

typedef Point<double> P;
using P = Point<double>;
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;
Expand Down
4 changes: 2 additions & 2 deletions content/geometry/kdTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "Point.h"

typedef long long T;
typedef Point<T> P;
using T = long long;
using P = Point<T>;
const T INF = numeric_limits<T>::max();

bool on_x(const P& a, const P& b) { return a.x < b.x; }
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/linearTransformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "Point.h"

typedef Point<double> P;
using P = Point<double>;
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));
Expand Down
2 changes: 1 addition & 1 deletion content/graph/CompressTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "LCA.h"

typedef vector<pair<int, int>> vpi;
using vpi = vector<pair<int, int>>;
vpi compressTree(LCA& lca, const vi& subset) {
static vi rev; rev.resize(sz(lca.time));
vi li = subset, &T = lca.time;
Expand Down
2 changes: 1 addition & 1 deletion content/graph/GomoryHu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "PushRelabel.h"

typedef array<ll, 3> Edge;
using Edge = array<ll, 3>;
vector<Edge> gomoryHu(int N, vector<Edge> ed) {
vector<Edge> tree;
vi par(N);
Expand Down
2 changes: 1 addition & 1 deletion content/graph/MaximalCliques.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<class F>
void cliques(vector<B>& eds, F f, B P = ~B(), B X={}, B R={}) {
if (!P.any()) { if (!X.any()) f(R); return; }
Expand Down
4 changes: 2 additions & 2 deletions content/graph/MaximumClique.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
* faster for sparse graphs.
* Status: stress-tested
*/
typedef vector<bitset<200>> vb;
using vb = vector<bitset<200>>;
struct Maxclique {
double limit=0.025, pk=0;
struct Vertex { int i, d=0; };
typedef vector<Vertex> vv;
using vv = vector<Vertex>;
vb e;
vv V;
vector<vi> C;
Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/ContinuedFractions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ll, ll> approximate(d x, ll N) {
ll LP = 0, LQ = 1, P = 1, Q = 0, inf = LLONG_MAX; d y = x;
for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/ModMulLL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/ModSum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions content/numerical/FastFourierTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
#pragma once

typedef complex<double> C;
typedef vector<double> vd;
using C = complex<double>;
using vd = vector<double>;
void fft(vector<C>& a) {
int n = sz(a), L = 31 - __builtin_clz(n);
static vector<complex<long double>> R(2, 1);
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/FastFourierTransformMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "FastFourierTransform.h"

typedef vector<ll> vl;
using vl = vector<ll>;
template<int M> vl convMod(const vl &a, const vl &b) {
if (a.empty() || b.empty()) return {};
vl res(sz(a) + sz(b) - 1);
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/HillClimbing.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
#pragma once

typedef array<double, 2> P;
using P = array<double, 2>;

template<class F> pair<double, P> hillClimb(P start, F f) {
pair<double, P> cur(f(start), start);
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/IntegrateAdaptive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class F>
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/LinearRecurrence.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const ll mod = 5; /** exclude-line */

typedef vector<ll> Poly;
using Poly = vector<ll>;
ll linearRec(Poly S, Poly tr, ll k) {
int n = sz(tr);

Expand Down
2 changes: 1 addition & 1 deletion content/numerical/NumberTheoreticTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ll> vl;
using vl = vector<ll>;
void ntt(vl &a) {
int n = sz(a), L = 31 - __builtin_clz(n);
static vl rt(2, 1);
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/PolyInterpolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#pragma once

typedef vector<double> vd;
using vd = vector<double>;
vd interpolate(vd x, vd y, int n) {
vd res(n), temp(n);
rep(k,0,n-1) rep(i,k+1,n)
Expand Down
6 changes: 3 additions & 3 deletions content/numerical/Simplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
#pragma once

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

const T eps = 1e-8, inf = 1/.0;
#define MP make_pair
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/SolveLinear.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
#pragma once

typedef vector<double> vd;
using vd = vector<double>;
const double eps = 1e-12;

int solveLinear(vector<vd>& A, vd& b, vd& x) {
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/SolveLinearBinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#pragma once

typedef bitset<1000> bs;
using bs = bitset<1000>;

int solveLinear(vector<bs>& A, vi& b, bs& x, int m) {
int n = sz(A), rank = 0, br;
Expand Down
2 changes: 1 addition & 1 deletion content/numerical/Tridiagonal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> tridiagonal(vector<T> diag, const vector<T>& super,
const vector<T>& sub, vector<T> b) {
int n = sz(b); vi tr(n);
Expand Down
6 changes: 3 additions & 3 deletions content/strings/Hashing-codeforces.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int M, class B>
struct A {
int x; B b; A(int x=0) : x(x), b(x) {}
Expand All @@ -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<H> ha, pw;
Expand Down
Loading