强大的缺省原


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

namespace Useful {
	const int N = 1e5+10;
	const int M = 1e6+10;
	const ll INF = 1e9+10;
	const ll mod = 1e9+7;
}
using namespace Useful;

namespace IO{
	char buf[1 << 20], *pa, *pb;
	inline char gc(){
		if(pa == pb) pb = (pa = buf) + fread(buf, 1, 1 << 20, stdin);
		return pa == pb ? ' ' : *pa++;
	}
	template<typename T>
	inline void read(T &x){
		x = 0;
		bool f = 1;
		char ch = gc();
		while(!isdigit(ch)){
			if(ch == '-') f = false;
			ch = gc();
		}
		while(isdigit(ch)){
			x = (x << 3) + (x << 1) + (ch ^ 48);
			ch = gc();
		}
		if(!f) x = -x;
	}
	template<typename T>
	void write(T x){
		if(x < 0){
			putchar('-');
			x = -x;
		}
		if(x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
};
using namespace IO;

namespace maths {
	inline void add(int &x, int v) {
		(x += v) >= mod ? x -= mod : 0;
	}
	inline void sub(int &x, int v) {
		x >= v ? x -= v : x += mod - v;
	}
	inline void mul(int &x, int v) {
		x = 1ll * x * v % mod;
	}
	inline int Plus(int x, int y) {
		return x + y >= mod ? x + y - mod : x + y;
	}
	inline int minu(int x, int y) {
		return x < y ? x + mod - y : x - y;
	}
	inline int prod(int x, int y) {
		return (ll)x * y % mod;
	}
	int expow(ll base, ll power) {
		ll mul = 1;
		while (power) {
			if (power) (mul *= base) %= mod;
			(base *= base) %= mod;
			power >>= 1;
		}
		return (int)mul;
	}
	int inv(ll x) {
		return expow(x, mod - 2);
	}
	inline int max(int x, int y) {
		return x > y ? x : y;
	}
	inline int min(int x, int y) {
		return x < y ? x : y;
	}
	inline void cmax(int &x, int y) {
		x = max(x, y);
	}
	inline void cmin(int &x, int y) {
		x = min(x, y);
	}
	
	template<typename T>
	inline void swap(T a, T b) {
		T c = a;
		a = b;
		b = c;
	}
};
using namespace maths;

namespace DS {
	template<typename T>
	struct STACK {
		T s[N];
		int stack_top = 0;

		inline void push(T x) {
			s[++stack_top] = x;
		}

		inline void pop() {
			--stack_top;
		}

		inline T top() {
			return s[stack_top];
		}
	};

	template<typename T>
	struct DEQUE {
		T front_stack[N], back_stack[N];
		int front_top = 0, back_top = 0;

		inline void push_front(T x) {
			front_stack[++front_top] = x;
		}

		inline void push_back(T x) {
			back_stack[++back_top] = x;
		}

		inline void pop_front() {
			if (front_top == 0) {
				if (back_top == 0) return;
				while (back_top) {
					front_stack[++front_top] = back_stack[back_top--];
				}
			}
			--front_top;
		}

		inline void pop_back() {
			if (back_top == 0) {
				if (front_top == 0) return;
				while (front_top) {
					back_stack[++back_top] = front_stack[front_top--];
				}
			}
			--back_top;
		}

		inline T front() {
			if (front_top == 0) {
				while (back_top) {
					front_stack[++front_top] = back_stack[back_top--];
				}
			}
			return front_stack[front_top];
		}

		inline T back() {
			if (back_top == 0) {
				while (front_top) {
					back_stack[++back_top] = front_stack[front_top--];
				}
			}
			return back_stack[back_top];
		}

		inline bool empty() {
			return front_top == 0 && back_top == 0;
		}
	};

	template<typename T>
	void merge_sort(T a[], int l, int r) {
		if (l >= r) return;
		int mid = (l + r) >> 1;
		merge_sort(a, l, mid);
		merge_sort(a, mid + 1, r);
		
		static T temp[N];
		int i = l, j = mid + 1, k = 0;
		while (i <= mid && j <= r) {
			if (a[i] <= a[j]) temp[k++] = a[i++];
			else temp[k++] = a[j++];
		}
		while (i <= mid) temp[k++] = a[i++];
		while (j <= r) temp[k++] = a[j++];
		for (int p = 0; p < k; ++p) {
			a[l + p] = temp[p];
		}
	}
}
using namespace DS;

#define fir first
#define sec second
mt19937 rnd(time(0));

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	return 0;
}
posted @ 2025-07-25 14:42  AC-wyr  阅读(8)  评论(0)    收藏  举报