C++ io template

· 542字 · 3分钟

C++ io template 🔗

#include <bits/stdc++.h>

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

#define int int64_t
#define endl '\n'
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using std::cin, std::cout, std::ios, std::string, std::vector, std::function;

template <class T = int> inline T in() { T ret; cin >> ret; return ret; }
template <class T = int> inline
void in(typename vector<T>::iterator it, int n) {
    for (int i = 0; i < n; i++, it++) *it = in<T>();
}
inline string in(char ch) {
    string s = "";
    char t;
    while ((t = cin.get()) != ch) s += t;
    return s;
}
inline int len(const char *p) { return (int)strlen(p); }
template <class T> inline int len(T p) { return (int)p.size(); }
template <bool flag = true> void print() {}
template <bool flag = true, class T>
void print(vector<T> val) {
    for (int i = 0; i < len(val); i++) {
        cout << val[i];
        if (i != len(val) - 1) cout << ' ';
    }
}
template <bool flag = true, class T> void print(T val) { cout << val; }
template <bool flag = true, class T, class... Args>
void print(T val, Args... args) {
    print<flag>(val);
    if (flag) cout << ' ';
    print<flag, Args...>(args...);
}
template <class... Args>
void printf(Args... args) { print<false>(args...); }
template <bool flag = true, class... Args>
void println(Args... args) { print<flag>(args...); cout << '\n'; }
template <class T> inline T abs(T x) { return x >= 0 ? x : -x; }
template <class T> inline T min(T x, T y) { return x < y ? x : y; }
template <class T, class... Args> inline T min(T x, Args... args) {
    return min(x, min(args...));
}
template <class T> inline T max(T x, T y) { return x > y ? x : y; }
template <class T, class... Args> inline T max(T x, Args... args) {
    return max(x, max(args...));
}
template <class T> inline int sgn(T x) { return x == 0 ? 0 : x / abs(x); }

enum BS_Pattern {
    BS_Last_Satisfy = 0,
    BS_Last_Unsatisfy = 1,
    BS_First_Satisfy = 2,
    BS_First_Unsatisfy = 3,
};

int bsearch(int L, int R, function<bool(int)> judger, BS_Pattern pat) {
    bool flag = pat & 2, rev = pat & 1;
    L -= flag, R += !flag;
    while (L + 1 < R)
        flag ^ rev ^ judger((L + R) / 2) ? L = (L + R) / 2 : R = (L + R) / 2;
    return flag ? R : L;
}

struct Hash {
	static u64 splitmix64(u64 x) {
        x = x + 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        x ^= x >> 31, x ^= x << 13;
		x ^= x >> 7, x ^= x << 17;
		return x;
	}
	size_t operator () (u64 x) const {
		static const u64 FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

template <class T1, class T2>
using map = std::unordered_map<T1, T2, Hash>;

void solve();

signed main() {
    #ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
    #endif
    #define MULTITEST
    #ifdef MULTITEST
    int T = in();
    while (T--)
    #endif
        solve();
    return 0;
}

void solve() {
    int n = in();
    println("Hello, World!");
}