自定义头文件"almighty.hpp"
持续更新
almighty.h内部内容:
#ifndef _ALMIGHTY_
#define _ALMIGHTY_
#include<bits/stdc++.h>
#define dnp Random_Numbers_Moonspace
#define dsm Data_Structure_Moonspace
using namespace std;
#define sd signed
#define ud unsigned
#define ct const
#define sc static
typedef int i4;
typedef long long i8;
typedef float f4;
typedef double f8;
typedef long double f16;
typedef void vd;
typedef bool bl;
typedef char cr;
typedef string STR;
#define ope operator
#define TE true
#define FE false
#define CI cin
#define CO cout
#define EL endl
#define Sf scanf
#define Pf printf
#define Gc getchar
#define Pc putchar
#define QIO_C98 ios::sync_with_stdio(FE), CI.tie(FE), CO.tie(FE);
#define QIO_C11 ios::sync_with_stdio(FE), CI.tie(nullptr), CO.tie(nullptr);
#define Fr for
#define Up(a, b, c, d) Fr (i8 a = b; a <= c; a += d)
#define Dn(a, b, c, d) Fr (i8 a = b; a >= c; a -= d)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019
#define e 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901157383418793070215408914993488416750924476146066808226480016847741185374234544243710753907774499206955170276183860626133138458300075204493382656029760673711320070932870912744374704723069697720931014169283681902551510865746377211125238978442505695369677078544996996794686445490598793163688923009879312773617821542499922957635148220826989519366803318252886939849646510582093923982948879332036250944311730123819706841614039701983767932068328237646480429531180232878250981945581530175671736133206981125099618188159304169035159888851934580727386673858942287922849989208680582574927961048419844436346324496848756023362482704197862320900216099023530436994184914631409343173814364054625315209618369088870701676839642437814059271456354906130310720851038375051011574770417189861068739696552126715468895703503
#define Cpi 3.14159265358979
#define Ce 2.71828182845904
vd read(i4&);
i4 Abs(i4);
i4 lowbit(i4);
i4 countbit(i4);
i4 qpow(i4, i4, ct i4);
i4 inv(i4, i4);
i4 gcd(i4, i4);
i4 qgcd(i4, i4);
i4 exgcd(i4, i4, i4&, i4&);
vd Swap(i4&, i4&);
namespace dnp {
i4 random_int(i4, i4);
f8 random_double(f8, f8);
vd kill_random();
vd random_int_vector(vector<i4> &, i4, i4, i4);
vd random_double_vector(vector<f8> &, i4, f8, f8);
}
template<class T> vd cin_arr(T[], i4, i4);
template<class T> vd cout_arr(T[], i4, i4, cr);
namespace dsm {
template<class Vec_name>
class Vec {
public:
i4 head, tail;
vector<Vec_name> Vec_array;
Vec_name ope[](i4);
vd fill_Vec(Vec_name);
vd fill_Vec(i4, i4, Vec_name);
Vec(i4, Vec_name);
Vec(i4, i4, Vec_name);
i4 PUSH_front(Vec_name);
i4 POP_front();
i4 PUSH_back(Vec_name);
i4 POP_back();
i4 Size();
vd sort_Vec(bl, bl);
vd sort_Vec(i4, i4, bl, bl);
vd cin_Vec();
vd cin_Vec(i4, i4);
vd cout_Vec(cr);
vd cout_Vec(i4, i4, cr);
};
}
#endif
almighty.hpp实现:
#include"almighty.h"
vd read(i4 &num) {
i4 sgn = 0;
cr ch = Gc();
while (~ch && !isdigit(ch)) sgn |= ch == '-', ch = Gc();
while (~ch && isdigit(ch)) num = (num << 1) + (num << 3) + (ch ^ 48), ch = Gc();
if (sgn) num = -num;
}
i4 Abs(i4 x) {
i4 a = x >> 31;
return (x ^ a) - a;
}
i4 lowbit(i4 x) {
return x & (-x);
}
i4 countbit(i4 x) {
i4 count = 0;
while (x) {
x = x & x - 1;
count ++;
}
return count;
}
i4 qpow(i4 a, i4 b, ct i4 p) {
i4 res = 1;
for (; b; b >>= 1ll, a = (i8)a * a % p)
if (b & 1)
res = (i8)res * a % p;
return res;
}
i4 inv(i4 n, i4 p) {
return qpow(n, p - 2, p);
}
i4 gcd(i4 a, i4 b) {
return !b ? a : gcd(b, a % b);
}
i4 qgcd(i4 a, i4 b) {
i4 x = __builtin_ctz(a), y = __builtin_ctz(b), z = min(x, y), k;
b >>= y;
while (a) {
a >>= x;
k = b - a;
x = __builtin_ctz(k);
if (a < b) b = a;
a = k < 0 ? -k : k;
}
return b << z;
}
i4 exgcd(i4 a, i4 b, i4 &x, i4 &y) {
if (!b) {
x = 1, y = 0;
return a;
}
i4 d = exgcd(b, a % b, x, y), t = x;
x = y, y = t - (a / b) * y;
return d;
}
vd Swap(i4 &a, i4 &b) {
a ^= b, b ^= a, a ^= b;
}
default_random_engine d(time(0));
i4 dnp::random_int(i4 l, i4 r) {
uniform_int_distribution<> u(l, r);
return u(d);
}
f8 dnp::random_double(f8 l, f8 r) {
uniform_real_distribution<> u(l, r);
return u(d);
}
vd dnp::kill_random() {
random_int(0, 1);
random_double(0.0, 1.0);
}
vd dnp::random_int_vector(vector<i4> &rand_vec, i4 num, i4 l, i4 r) {
rand_vec.clear();
Up(i, 1, num, 1) rand_vec.push_back(random_int(l, r));
}
vd dnp::random_double_vector(vector<f8> &rand_vec, i4 num, f8 l, f8 r) {
rand_vec.clear();
Up(i, 1, num, 1) rand_vec.push_back(random_double(l, r));
}
template<class T> vd cin_arr(T arr[], i4 first, i4 size) {
Up(i, 0, size - 1, 1) CI >> arr[i];
}
template<class T> vd cout_arr(T arr[], i4 first, i4 size, cr _and_) {
Up(i, 0, size - 1, 1) CO << arr[i] << _and_;
}
template<class Vec_name> Vec_name dsm::Vec<Vec_name>::ope[](i4 index) {
return Vec_array.at(index);
}
template<class Vec_name> vd dsm::Vec<Vec_name>::fill_Vec(Vec_name content) {
//if (Vec_array.size() <= tail - head) Vec_array.resize(tail + 5);
Up(i, head, tail, 1) Vec_array.at(i) = content;
}
template<class Vec_name> vd dsm::Vec<Vec_name>::fill_Vec(i4 l, i4 r, Vec_name content) {
//if (Vec_array.size() <= tail - head) Vec_array.resize(tail + 5);
l = max(0, l), r = min(tail + 2, r);
Up(i, l, r, 1) Vec_array.at(i) = content;
}
template<class Vec_name> dsm::Vec<Vec_name>::Vec(i4 r, Vec_name content) {
head = 0, tail = max(1, r);
Vec_array.resize(tail + 10);
fill_Vec(0, tail, 0);
fill_Vec(content);
}
template<class Vec_name> dsm::Vec<Vec_name>::Vec(i4 l, i4 r, Vec_name content) {
head = max(min(l, r), 0), tail = max(max(l, r), 1);
Vec_array.resize(tail + 10);
fill_Vec(0, tail, 0);
fill_Vec(content);
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::PUSH_front(Vec_name push) {
if (!head) return -1;
Vec_array[-- head] = push;
return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::POP_front() {
if (head >= tail) return -1;
++ head;
return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::PUSH_back(Vec_name push) {
if (tail >= Vec_array.size()) Vec_array.resize(tail + 10, 0);
Vec_array[++ tail] = push;
return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::POP_back() {
if (tail <= head) return -1;
-- tail;
return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::Size() {
if (head > tail) return -1;
return tail - head + 1;
}
template<class Vec_name> vd dsm::Vec<Vec_name>::sort_Vec(bl way, bl order) {
if (way)
if (order) sort(Vec_array.begin() + head, Vec_array.begin() + tail);
else sort(Vec_array.begin() + head, Vec_array.begin() + tail, greater<Vec_name>());
else
if (order) table_sort(Vec_array.begin() + head, Vec_array.begin() + tail);
else table_sort(Vec_array.begin() + head, Vec_array.begin() + tail, greater<Vec_name>());
}
template<class Vec_name> vd dsm::Vec<Vec_name>::sort_Vec(i4 l, i4 r, bl way, bl order) {
if (way)
if (order) sort(Vec_array.begin() + l, Vec_array.begin() + r);
else sort(Vec_array.begin() + l, Vec_array.begin() + r, greater<Vec_name>());
else
if (order) table_sort(Vec_array.begin() + l, Vec_array.begin() + r);
else table_sort(Vec_array.begin() + l, Vec_array.begin() + r, greater<Vec_name>());
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cin_Vec() {
Up(i, head, tail, 1) CI >> Vec_array.at(i);
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cin_Vec(i4 l, i4 r) {
l = max(0, min(l, r)), r = max(0, max(l, r));
Up(i, l, r, 1) CI >> Vec_array.at(i);
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cout_Vec(cr _and_) {
Up(i, head, tail, 1) CO << Vec_array.at(i) << _and_;
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cout_Vec(i4 l, i4 r, cr _and_) {
l = max(0, min(l, r)), r = max(0, max(l, r));
Up(i, l, r, 1) CO << Vec_array.at(i) << _and_;
}
标签:vd,i4,tail,Vec,头文件,array,My,define From: https://www.cnblogs.com/vectorSpace-blog/p/17738096.html