跳到正文

剪贴板

剪贴板 716shsvr

原文
剪贴板信息

剪贴板信息

收录
更新

缺省源:

C++
#include<bits/stdc++.h>
//#define int long long
#define For(i, a, b) for(int i = (a); i <= (b); i++)
#define Rof(i, a, b) for(int i = (a); i >= (b); i--)
using namespace std;
const int N = 5e5 + 5;

void Solve(){

}
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int T = 1; //cin >> T;
	while(T--) Solve();
	return 0;
}

快读(fread):

C++
namespace FastIn{
	const int SIZE = 1 << 23;
	char BUF[SIZE], *P1 = BUF, *P2 = BUF;
	#define getchar() (P1 == P2 && (P2 = (P1 = BUF) + fread(BUF, 1, SIZE, stdin), P1 == P2) ? EOF : *P1++)
	int read(){
		int x = 0, f = 1; char ch = getchar();
		while(!isdigit(ch)){if(ch == '-') f = -1; ch = getchar();}
		while(isdigit(ch)){x = x * 10 + (ch & 15); ch = getchar();}
		return x * f;
	}
	template<class T>
	void read(T &x){
		x = 0; T f = 1; char ch = getchar();
		while(!isdigit(ch)){if(ch == '-') f = -1; ch = getchar();}
		while(isdigit(ch)){x = x * 10 + (ch & 15); ch = getchar();}
		x = x * f;
	}
	template<class T, class... Args>
	void read(T &x, Args &...args){read(x); read(args...);}
}
using FastIn::read;

自动取模:

C++
struct mint{
	int x;
	mint():x(0){}
	mint(int64_t y, bool o = 0){x = o ? y : (y % mod + mod) % mod;}
	friend const mint qpow(mint a, int64_t b);
	friend mint operator+(const mint &a, const mint &b){mint res(a.x + b.x, 1); if(res.x >= mod) res.x -= mod; return res;}
	friend mint operator-(const mint &a, const mint &b){mint res(a.x - b.x, 1); if(res.x < 0) res.x += mod; return res;}
	friend mint operator*(const mint &a, const mint &b){return mint(1ll * a.x * b.x % mod, 1);}
	friend mint operator/(const mint &a, const mint &b){return mint(1ll * a.x * qpow(b, mod - 2).x % mod, 1);}
	friend bool operator!(const mint &a){return !a.x;}
	friend bool operator==(const mint &a, const mint &b){return a.x == b.x;}
	friend bool operator!=(const mint &a, const mint &b){return a.x != b.x;}
	friend bool operator>(const mint &a, const mint &b){return a.x > b.x;}
	friend bool operator<(const mint &a, const mint &b){return a.x < b.x;}
	mint& operator+=(const mint &b){x += b.x; if(x >= mod) x -= mod; return *this;}
	mint& operator-=(const mint &b){x -= b.x; if(x < 0) x += mod; return *this;}
	mint& operator*=(const mint &b){x = 1ll * x * b.x % mod; return *this;}
	mint& operator/=(const mint &b){x = 1ll * x * qpow(b, mod - 2).x % mod; return *this;}
	friend istream& operator>>(istream &is, mint &x){int v; is >> v; x = mint(v); return is;}
	friend ostream& operator<<(ostream &os, mint &x){os << x.x; return os;}
};
const mint qpow(mint a, int64_t b){
	mint res(1, 1);
	for(; b; a *= a, b /= 2) if(b & 1) res *= a;
	return res;
}

哈希表避免被卡的方式:

C++
struct custom_hash{
	static uint64_t splitmix64(uint64_t x){
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}
	size_t operator()(uint64_t x) const{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
unordered_map<int, int, custom_hash> mp;

Sublime 配置文件:

代码
//以下为编译系统配置
{
    "cmd": ["g++", "-static-libgcc", "-Wl,--stack=998244353", "-Wall", "${file}","-std=c++17", "-o","${file_path}/${file_base_name}"],
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "shell": true,
    "encoding": "utf-8",
    "variants":
    [
        {
            "name": "Compile Only",
            "cmd": ["cmd", "/C", "g++", "-static-libgcc", "-Wl,--stack=998244353", "-Wall", "${file}","-std=c++17", "-o","${file_path}/${file_base_name}"],
        },
        {
            "name": "Run Only",
            "cmd": ["start","cmd","/c", "${file_base_name} & echo. & pause"],
        },
        {
            "name": "Compile & Run",
            "cmd": ["cmd", "/C", "g++", "-static-libgcc", "-Wl,--stack=998244353", "-Wall", "${file}","-std=c++17", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_base_name} & echo. & pause"],
        }
    ]
}

//以下为快捷键设置
[
	{ "keys": ["f9"], "command": "build", "args": {"variant": "Compile Only"}},
	{ "keys": ["f10"], "command": "build", "args": {"variant": "Run Only"}},
	{ "keys": ["f11"], "command": "build", "args": {"variant": "Compile & Run"}}
]

VSCode 代码片段配置:

C++
{
	"default_source": {
		"prefix": "Orz",
		"body": [
			"#include<bits/stdc++.h>",
			"//#define int long long",
			"#define For(i, a, b) for(int i = (a); i <= (b); i++)",
			"#define Rof(i, a, b) for(int i = (a); i >= (b); i--)",
			"using namespace std;",
			"const int N = 5e5 + 5;",
			"",
			"void Solve(){",
			"",
			"}",
			"signed main(){",
			"\tcin.tie(0)->sync_with_stdio(0);",
			"\tint T = 1; //cin >> T;",
			"\twhile(T--) Solve();",
			"\treturn 0;",
			"}"
		],
		"description": "default_source"
	},
	"check_max_min": {
		"prefix": "cmax",
		"body": [
			"template<typename T> void cmax(T &x, T y){x = max(x, y);}",
			"template<typename T> void cmin(T &x, T y){x = min(x, y);}"
		],
		"description": "check_max_min"
	},
	"custom_hash": {
		"prefix": "custom_hash",
		"body": [
			"struct custom_hash{",
			"\tstatic uint64_t splitmix64(uint64_t x){",
			"\t\tx += 0x9e3779b97f4a7c15;",
			"\t\tx = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;",
			"\t\tx = (x ^ (x >> 27)) * 0x94d049bb133111eb;",
			"\t\treturn x ^ (x >> 31);",
			"\t}",
			"\tsize_t operator()(uint64_t x) const{",
			"\t\tstatic const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();",
			"\t\treturn splitmix64(x + FIXED_RANDOM);",
			"\t}",
			"};"
		],
	"description": "custom_hash"
	},
	"modint": {
		"prefix": "mint",
		"body": [
			"struct mint{",
			"\tint x;",
			"\tmint():x(0){}",
			"\tmint(int64_t y, bool o = 0){x = o ? y : (y % mod + mod) % mod;}",
			"\tfriend const mint qpow(mint a, int64_t b);",
			"\tfriend mint operator+(const mint &a, const mint &b){mint res(a.x + b.x, 1); if(res.x >= mod) res.x -= mod; return res;}",
			"\tfriend mint operator-(const mint &a, const mint &b){mint res(a.x - b.x, 1); if(res.x < 0) res.x += mod; return res;}",
			"\tfriend mint operator*(const mint &a, const mint &b){return mint(1ll * a.x * b.x % mod, 1);}",
			"\tfriend mint operator/(const mint &a, const mint &b){return mint(1ll * a.x * qpow(b, mod - 2).x % mod, 1);}",
			"\tfriend bool operator!(const mint &a){return !a.x;}",
			"\tfriend bool operator==(const mint &a, const mint &b){return a.x == b.x;}",
			"\tfriend bool operator!=(const mint &a, const mint &b){return a.x != b.x;}",
			"\tfriend bool operator>(const mint &a, const mint &b){return a.x > b.x;}",
			"\tfriend bool operator<(const mint &a, const mint &b){return a.x < b.x;}",
			"\tmint& operator+=(const mint &b){x += b.x; if(x >= mod) x -= mod; return *this;}",
			"\tmint& operator-=(const mint &b){x -= b.x; if(x < 0) x += mod; return *this;}",
			"\tmint& operator*=(const mint &b){x = 1ll * x * b.x % mod; return *this;}",
			"\tmint& operator/=(const mint &b){x = 1ll * x * qpow(b, mod - 2).x % mod; return *this;}",
			"\tfriend istream& operator>>(istream &is, mint &x){int v; is >> v; x = mint(v); return is;}",
			"\tfriend ostream& operator<<(ostream &os, mint x){os << x.x; return os;}",
			"};",
			"const mint qpow(mint a, int64_t b){",
			"\tmint res(1, 1);",
			"\tfor(; b; a *= a, b /= 2) if(b & 1) res *= a;",
			"\treturn res;",
			"}"
		],
		"description": "modint"
	},
	"fast_read": {
		"prefix": "read",
		"body": [
			"namespace FastIn{",
			"\tconst int SIZE = 1 << 23;",
			"\tchar BUF[SIZE], *P1 = BUF, *P2 = BUF;",
			"\t#define getchar() (P1 == P2 && (P2 = (P1 = BUF) + fread(BUF, 1, SIZE, stdin), P1 == P2) ? EOF : *P1++)",
			"\tint read(){",
			"\t\tint x = 0, f = 1; char ch = getchar();",
			"\t\twhile(!isdigit(ch)){if(ch == '-') f = -1; ch = getchar();}",
			"\t\twhile(isdigit(ch)){x = x * 10 + (ch & 15); ch = getchar();}",
			"\t\treturn x * f;",
			"\t}",
			"\ttemplate<class T>",
			"\tvoid read(T &x){",
			"\t\tx = 0; T f = 1; char ch = getchar();",
			"\t\twhile(!isdigit(ch)){if(ch == '-') f = -1; ch = getchar();}",
			"\t\twhile(isdigit(ch)){x = x * 10 + (ch & 15); ch = getchar();}",
			"\t\tx = x * f;",
			"\t}",
			"\ttemplate<class T, class... Args>",
			"\tvoid read(T &x, Args &...args){read(x); read(args...);}",
			"}",
			"using FastIn::read;"
		],
		"description": "fast_read"
	},
	"segtree": {
		"prefix": "segtree",
		"body": [
			"template<typename Info>",
			"struct segtree{",
			"\tint n; vector<Info> tr;",
			"\tsegtree():n(0){}",
			"\tsegtree(vector<Info> vec){build(vec);}",
			"\tsegtree(int _n, Info _w = Info()){build(vector<Info>(_n, _w));}",
			"\tvoid init(vector<Info> vec){build(vec);}",
			"\tvoid init(int _n, Info _w = Info()){build(vector<Info>(_n, _w));}",
			"\t#define ls now << 1",
			"\t#define rs now << 1 | 1",
			"\tvoid pushup(int now){tr[now] = tr[ls] + tr[rs];}",
			"\tvoid build(vector<Info> vec){",
			"\t\tn = vec.size();",
			"\t\tauto dfs = [&](auto self, int l, int r, int now){",
			"\t\t\tif(l == r) return tr[now] = vec[l - 1], void();",
			"\t\t\tint mid = (l + r) >> 1;",
			"\t\t\tself(self, l, mid, ls); self(self, mid + 1, r, rs);",
			"\t\t\tpushup(now);",
			"\t\t};",
			"\t\ttr.resize((n << 2) + 5); dfs(dfs, 1, n, 1);",
			"\t}",
			"\tvoid modify(int p, Info v, int l, int r, int now){",
			"\t\tif(l == r) return tr[now] = v, void();",
			"\t\tint mid = (l + r) >> 1;",
			"\t\tif(p <= mid) modify(p, v, l, mid, ls);",
			"\t\telse modify(p, v, mid + 1, r, rs);",
			"\t\tpushup(now);",
			"\t}",
			"\tInfo query(int x, int y, int l, int r, int now){",
			"\t\tif(x <= l && r <= y) return tr[now];",
			"\t\tint mid = (l + r) >> 1;",
			"\t\tif(y <= mid) return query(x, y, l, mid, ls);",
			"\t\tif(x > mid) return query(x, y, mid + 1, r, rs);",
			"\t\treturn query(x, y, l, mid, ls) + query(x, y, mid + 1, r, rs);",
			"\t}",
			"\tvoid modify(int p, Info v){modify(p, v, 1, n, 1);}",
			"\tInfo query(int l, int r){return query(l, r, 1, n, 1);}",
			"\t#undef ls",
			"\t#undef rs",
			"};",
			"struct Info{",
			"\t",
			"};",
			"Info operator+(const Info &a, const Info &b){",
			"\tInfo c;",
			"",
			"\treturn c;",
			"}"
		],
		"description": "segtree"
	},
	"segtree_lazy": {
		"prefix": "segtree_lazy",
		"body": [
			"template<typename Info, typename Tag>",
			"struct segtree_lazy{",
			"\tint n; vector<Info> tr; vector<Tag> lazy;",
			"\tsegtree_lazy():n(0){}",
			"\tsegtree_lazy(vector<Info> vec){build(vec);}",
			"\tsegtree_lazy(int _n, Info _w = Info()){build(vector<Info>(_n, _w));}",
			"\tvoid init(vector<Info> vec){build(vec);}",
			"\tvoid init(int _n, Info _w = Info()){build(vector<Info>(_n, _w));}",
			"\t#define ls now << 1",
			"\t#define rs now << 1 | 1",
			"\tvoid pushup(int now){tr[now] = tr[ls] + tr[rs];}",
			"\tvoid apply(int now, Tag w){tr[now].apply(w); lazy[now].apply(w);}",
			"\tvoid pushdown(int now){apply(ls, lazy[now]); apply(rs, lazy[now]); lazy[now] = Tag();}",
			"\tvoid build(vector<Info> vec){",
			"\t\tn = vec.size();",
			"\t\tauto dfs = [&](auto self, int l, int r, int now){",
			"\t\t\tif(l == r) return tr[now] = vec[l - 1], void();",
			"\t\t\tint mid = (l  + r) >> 1;",
			"\t\t\tself(self, l, mid, now * 2); self(self, mid + 1, r, now * 2 + 1);",
			"\t\t\tpushup(now); ",
			"\t\t};",
			"\t\ttr.resize((n << 2) + 5); lazy.resize((n << 2) + 5); dfs(dfs, 1, n, 1);",
			"\t}",
			"\tvoid update(int p, Info v, int l, int r, int now){",
			"\t\tif(l == r) return tr[now] = v, void();",
			"\t\tint mid = (l + r) >> 1; pushdown(now);",
			"\t\tif(p <= mid) update(p, v, l, mid, ls);",
			"\t\telse update(p, v, mid + 1, r, rs);",
			"\t\tpushup(now);",
			"\t}",
			"\tvoid modify(int x, int y, Tag w, int l, int r, int now){",
			"\t\tif(x <= l && r <= y) return apply(now, w);",
			"\t\tint mid = (l + r) >> 1; pushdown(now);",
			"\t\tif(x <= mid) modify(x, y, w, l, mid, ls);",
			"\t\tif(y > mid) modify(x, y, w, mid + 1, r, rs);",
			"\t\tpushup(now);",
			"\t}",
			"\tInfo query(int x, int y, int l, int r, int now){",
			"\t\tif(x <= l && r <= y) return tr[now];",
			"\t\tint mid = (l + r) >> 1; pushdown(now);",
			"\t\tif(y <= mid) return query(x, y, l, mid, ls);",
			"\t\tif(x > mid) return query(x, y, mid + 1, r, rs);",
			"\t\treturn query(x, y, l, mid, ls) + query(x, y, mid + 1, r, rs);",
			"\t}",
			"\tvoid update(int p, Info v){update(p, v, 1, n, 1);}",
			"\tvoid modify(int l, int r, Tag w){modify(l, r, w, 1, n, 1);}",
			"\tInfo query(int l, int r){return query(l, r, 1, n, 1);}",
			"\t#undef ls",
			"\t#undef rs",
			"};",
			"struct Tag{",
			"",
			"\tvoid apply(const Tag &w){",
			"",
			"\t}",
			"};",
			"struct Info{",
			"",
			"\tvoid apply(const Tag &w){",
			"",
			"\t}",
			"};",
			"Info operator+(const Info &a, const Info &b){",
			"\tInfo c;",
			"",
			"\treturn c;",
			"}"
		],
		"description": "segtree_lazy"
	}
}

spell left stay cycle coil stick adult heavy canvas fish about wise