首页 > 其他 > 详细

【基础】标准模板

时间:2021-01-12 16:54:31      阅读:16      评论:0      收藏:0      [点我收藏+]
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define srt(x) sort(all(x))
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define msv(x, v) memset((x), (v), sizeof(x))
#define ms(x) memset(x, 0, sizeof(x))
#define dbg(x) cerr << #x " = " << (x) << endl

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int MOD = 1000000007;
//const int MOD = 998244353;

struct Scanner {

    bool hasNext = 1;

    int nextInt() {
        int res = 0;
        char flag = 1, ch = getchar();
        while(ch != EOF && !isdigit(ch)) {
            flag = (ch == ‘-‘) ? -flag : flag;
            ch = getchar();
        }
        while(ch != EOF && isdigit(ch)) {
            res = res * 10 + (ch - ‘0‘);
            ch = getchar();
        }
        hasNext &= (ch != EOF);
        return res;
    }

    ll nextLL() {
        ll res = 0;
        char flag = 1, ch = getchar();
        while(ch != EOF && !isdigit(ch)) {
            flag = (ch == ‘-‘) ? -flag : flag;
            ch = getchar();
        }
        while(ch != EOF && isdigit(ch)) {
            res = res * 10 + (ch - ‘0‘);
            ch = getchar();
        }
        hasNext &= (ch != EOF);
        return res;
    }

    char nextChar() {
        char ch = getchar();
        while(ch != EOF && isspace(ch))
            ch = getchar();
        hasNext &= (ch != EOF);
        return ch;
    }

    int nextString(char *str) {
        int len = 0;
        char ch = getchar();
        while(ch != EOF && isspace(ch))
            ch = getchar();
        while(ch != EOF && !isspace(ch)) {
            str[++len] = ch;
            ch = getchar();
        }
        str[len + 1] = 0;
        hasNext &= (ch != EOF);
        return len;
    }

} sc;

void rd(int &x) {
    x = sc.nextInt();
}

void rd(ll &x) {
    x = sc.nextLL();
}

void rd(char &x) {
    x = sc.nextChar();
}

void rd(char* x) {
    sc.nextString(x);
}

template <typename T>
void cmin(T &x, T y) {
    if(y < x)
        x = y;
}

template <typename T>
void cmax(T &x, T y) {
    if(y > x)
        x = y;
}

/* begin */

struct Solver {

    void InitOnce() {
//        int t = sc.nextInt();
//        dbg(t);
    }

    void Read() {
    }

    void Solve() {
    }

} solver;

/* end */

int main() {
#ifdef LOCAL
    freopen("A.txt", "r", stdin);
#endif // LOCAL
    solver.InitOnce();
    while(1) {
        solver.Read();
        if(!sc.hasNext)
            break;
        solver.Solve();
        if(!sc.hasNext)
            break;
    }
    return 0;
}

【基础】标准模板

原文:https://www.cnblogs.com/purinliang/p/14267318.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!