跳到正文

算法·理论

缺省源

Aaron_Romeo约 11 分钟
原文
文章信息与版本

文章信息

发布
2025年1月7日
收录
2025年12月12日
更新
2026年11月18日
篇幅
约 11 分钟
获赞
1

版本

  1. v1当前
C++
#include <iostream>
#include <algorithm>
#include <cstring>
#include <ext/pb_ds/assoc_container.hpp>
#include <vector>
#include <bitset>
#include <random>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
typedef unsigned __int128 u128;
typedef __int128 i128;
typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;
bool BG;
namespace IO
{
#ifdef LOCAL
	const int N = 1;
#else
	const int N = 1 << 23;
#endif
	template<typename T> struct flt {T num; int pcs; flt() {num = 0, pcs = 6;} flt(const T &_num, const int &_pcs) {num = _num, pcs = _pcs;}};
	struct I {FILE *in; char ibuf[N], *p1, *p2; I() {*this = stdin;} I(FILE *f) {*this = f;} I & operator = (FILE *f) {return p1 = p2 = ibuf, in = f, *this;} bool flush() {return p1 != p2 || (p2 = (p1 = ibuf) + fread(ibuf, 1, N, in), p1 != p2);} char gc() {return !flush() ? EOF : *p1 ++ ;} int getline(std :: string &s) {s.clear(); char c; while (c = gc(), c != 10 && c != EOF) if (c != 13) s += c; return s.length();} int getline(char *s) {char *t = s; char c; while (c = gc(), c != 10 && c != EOF) if (c != 13) *t ++ = c; *t = 0; return t - s;} int getdigit() {char c; while (!isdigit(c = gc()) && c != EOF); return c == EOF ? 0 : c - '0';} template<typename T> T readnum() {bool f = 0; T x = 0; char c; while (!isdigit(c = gc()) && c != EOF) f = c == '-'; while (isdigit(c)) x = x * 10 + c - '0', c = gc(); if (c == '.') for (T v = 0.1; isdigit(c = gc()); v *= 0.1) x += v * (c - '0'); return f ? -x : x;} template<typename T, typename = std :: enable_if_t<std :: is_arithmetic<T> :: value || std :: is_same<T, __int128> :: value || std :: is_same<T, unsigned __int128> :: value || std :: is_same<T, bool> :: value>> operator T() {return readnum<T>();} operator char() {char c = gc(); return c == EOF ? 0 : c;} operator std :: string() {std :: string s; char c; while (c = gc(), c == ' ' || c == 10 || c == 13 || c == 9); while (c != ' ' && c != 10 && c != 9 && c != EOF) {if (c != 13) s += c; c = gc();} return s;} I & operator () () {return *this;} template<typename T> int operator () (T &x) {return x = operator T(), 0;} int operator () (char *s) {char *t = s, c; while (c = gc(), c == ' ' || c == 10 || c == 13 || c == 9); while (c != ' ' && c != 10 && c != 9 && c != EOF) {if (c != 13) *t ++ = c; c = gc();} *t = 0; return t - s;} template<typename T, typename ...Args> typename std :: enable_if<std :: is_pointer<typename std :: remove_reference<T> :: type> :: value || std::is_array<T> :: value, int> :: type operator () (T x, Args &&...args) {return operator () (x) + operator () (std :: forward<Args> (args)...);} template<typename T, typename ...Args> typename std :: enable_if<!std :: is_pointer<typename std :: remove_reference<T> :: type> :: value && !std::is_array<T> :: value, int> :: type operator () (T &x, Args &&...args) {return operator () (x) + operator () (std :: forward<Args> (args)...);}};
	struct O {FILE *out; char obuf[N], *p3; O() {p3 = obuf, out = stdout;} O(FILE *f) {p3 = obuf, out = f;} ~O() {flush();} O & operator = (FILE *f) {return flush(), out = f, *this;} void flush() {fwrite(obuf, p3 - obuf, 1, out), p3 = obuf;} int close() {return flush(), fclose(out);} void pc(char x) {*p3 ++ = x; if (p3 - obuf == N) flush();} template<typename ...Args> int printf(const char *format, Args ...args) {char s[1 << 23], *t = s; sprintf(s, format, args...); while (*t) pc(*t ++ ); return t - s;} template<typename T> void writeint(const T &x) {T y = x; if (!y) return pc('0'); if (y < 0) pc('-'); char c[1 << 6]; int len = 0; if (y < 0) while (y) c[ ++ len] = -(y % 10) + '0', y /= 10; else while (y) c[ ++ len] = y % 10 + '0', y /= 10; while (len) pc(c[len -- ]);} template<typename T> void operator () (const T &x) {writeint<T>(x);} void operator () (const char &x) {pc(x);} void operator () (const std :: string &s) {for (char i : s) pc(i);} void operator () (char *s) {while (*s) pc(*s ++ );} void operator () (const char *s) {while (*s) pc(*s ++ );} template<typename T> void writefloat(const flt<T> &x) {T y = x.num; int r = x.pcs; if (y < 0) pc('-'), y = -y; T f = 5; for (int i = 1; i <= r + 1; i ++ ) f *= 0.1; y += f; char c[1 << 8]; int len = 0; if (y < 1) pc('0'); for (T s = std :: floor(y), t; s >= 1; s = t) t = std :: floor(s * 0.1), c[ ++ len] = std :: max((int)(s - t * 10), 0) + '0'; while (len) pc(c[len -- ]); if (!r) return ; pc('.'); for (T s = (y - std :: floor(y)) * 10; r; s = (s - std :: floor(s)) * 10, r -- ) pc((int)s + '0');} template<typename T> void operator () (const flt<T> &x) {writefloat<T>(x);} void operator () (const float &x) {writefloat(flt<float>(x, 6));} void operator () (const double &x) {writefloat(flt<double>(x, 6));} void operator () (const long double &x) {writefloat(flt<long double>(x, 6));} template<typename T, typename ...Args> void operator () (const T &x, const Args &...args) {operator () (x), operator () (args...);}};
} IO :: I read; IO :: O write, debug = stderr; using IO :: flt;
namespace solve
{
	
	int main()
	{
		
		return 0;
	}
}
bool ED;
int main()
{
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	// freopen("f:/study/Informatics/code/in.txt", "r", stdin);
	// freopen("f:/study/Informatics/code/out.txt", "w", stdout);
#elif defined ONLINE_JUDGE
	// freopen("name.in", "r", stdin);
	// freopen("name.out", "w", stdout);
#else
	// freopen("name.in", "r", stdin);
	// freopen("name.out", "w", stdout);
#endif
#ifdef LOCAL
	debug("Start\n\n");
#endif
	int T = 1;
	while (T -- ) solve :: main();
#ifdef LOCAL
	debug("\n\n", flt<double>(std :: clock() / 1000.0, 2), "s ", flt<double>(std :: abs(&BG - &ED) / 1024.0 / 1024.0, 1), "MB\n");
#endif
	return 0;
}
原文