zoukankan      html  css  js  c++  java
  • ACM模板

    struct fastio{
        char s[100005];
        int it,len;
        fastio(){it=len=0;}
        inline char get(){
            if(it<len)return s[it++];it=0;
            len=fread(s,1,100000,stdin);
            if(len==0)return EOF;else return s[it++];
        }
        bool notend(){
            char c=get();
            while(c==' '||c=='
    ')c=get();
            if(it>0)it--;
            return c!=EOF;
        }
    }_buff;
    #define read(x) x=getnum()
    #define write(x) putnum(x),putchar('
    ')
    
    inline LL getnum(){
        LL r=0;bool ng=0;char c;c=_buff.get();
        while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
        if(c=='-')ng=1,c=_buff.get();
        while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
        return ng?-r:r;
    }
    template<class T> inline void putnum(T x){
        if(x<0)putchar('-'),x=-x;
        register short a[20]={},sz=0;
        while(x)a[sz++]=x%10,x/=10;
        if(sz==0)putchar('0');
        for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
    }
    inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
    

    常用头文件:

    g++ -std=c++14 A.cpp -o A -D LH_LOCAL

    /*
    **链接**
    传送门: [here]()
    **题意**
    **思路**
    **备注**
    */
    #pragma comment(linker, "/STACK:102400000,102400000")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize(3,"Ofast","inline")
    #pragma GCC optimize("Ofast,no-stack-protector")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    #define fi first
    #define se second
    #define o2(x) (x) * (x)
    #define mk make_pair
    #define eb emplace_back
    #define SZ(x) ((int)(x).size())
    #define all(x) (x).begin(), (x).end()
    #define clr(a, b) memset((a), (b), sizeof((a)))
    #define rep(i, s, t) for(register int i = (s), LIM=(t); i < LIM; ++i)
    #define per(i, s, t) for(register int i = (s), LIM=(t); i >= LIM; --i)
    #define GKD std::ios::sync_with_stdio(false);cin.tie(0)
    #define my_unique(x) sort(all(x)), x.erase(unique(all(x)), x.end())
    using namespace std;
    typedef long long LL;
    typedef long long int64;
    typedef unsigned long long uint64;
    typedef pair<int, int> pii;
    // mt19937 rng(time(NULL));//std::clock()
    // mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(arr, arr + n, rng64);
    inline int64 read() {
        int64 x = 0;int f = 0;char ch = getchar();
        while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
        while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch =
        getchar(); return x = f ? -x : x;
    }
    inline void write(int64 x, bool f = true) {
        if (x == 0) {putchar('0'); if(f)putchar('
    ');else putchar(' ');return;}
        if (x < 0) {putchar('-');x = -x;}
        static char s[23];
        int l = 0;
        while (x != 0)s[l++] = x % 10 + 48, x /= 10;
        while (l)putchar(s[--l]);
        if(f)putchar('
    ');else putchar(' ');
    }
    int lowbit(int x) { return x & (-x); }
    template <class T>
    T big(const T &a1, const T &a2) {return a1 > a2 ? a1 : a2;}
    template <class T>
    T sml(const T &a1, const T &a2) {return a1 < a2 ? a1 : a2;}
    template <typename T, typename... R>
    T big(const T &f, const R &... r) {return big(f, big(r...));}
    template <typename T, typename... R>
    T sml(const T &f, const R &... r) {return sml(f, sml(r...));}
    void debug_out() { cout << '
    '; }
    template <typename T, typename... R>
    void debug_out(const T &f, const R &... r) {
        cout << f << " ";
        debug_out(r...);
    }
    #ifdef LH_LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);
    #else
    #define debug(...) ;
    #endif
    /*================Header Template==============*/
    const int mod = 998244353;// 998244353
    const int INF = 0x3f3f3f3f;
    int ksm(int a, int64 b, int kmod = mod) {int res = 1;for(;b > 0;b >>= 1, a = (int64)a * a % kmod) if(b &1) res = (int64)res * a % kmod;return res;}
    const int MXN = 2e5 + 5;
    
    int n, m;
    void work() {
        n = read();
    }
    int main() {
    #ifdef LH_LOCAL
        freopen("D:/ACM/mtxt/in.txt", "r", stdin);
        // freopen("D:/ACM/mtxt/out.txt", "w", stdout);
    #endif
        for(int cas = 1, tim = 1; cas <= tim; ++ cas) {
            // printf("Case #%d:
    ", cas);
            work();
        }
    #ifdef LH_LOCAL
        cout << "time cost:" << 1.0 * clock() / CLOCKS_PER_SEC << "s" << endl;
    #endif
        return 0;
    }
    

    vscode snippets

    {
    	// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
    	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
    	// same ids are connected.
    	// Example:
    	// "Print to console": {
    	// 	"prefix": "log",
    	// 	"body": [
    	// 		"console.log('$1');",
    	// 		"$2"
    	// 	],
    	// 	"description": "Log output to console"
    	// },
    	"简单线段树模板": {
    		"prefix": "mb_seg1",
    		"body": [
    			"class SegT1 {",
    "    public:",
    "#define lson rt << 1",
    "#define rson rt << 1 | 1",
    "    int N;",
    "    vector<int> lazy;",
    "    vector<int64_t> sum;",
    "    SegT1(int N = 0) : N(N), lazy((N << 2) + 5), sum((N << 2) + 5) {}",
    "    void pop(int rt) {",
    "        sum[rt] = (sum[lson] + sum[rson]);",
    "    }",
    "    void build(int l, int r, int rt) {",
    "        lazy[rt] = 0;",
    "        if(l == r) {",
    "            sum[rt] = 1;",
    "            return ;",
    "        }",
    "        int mid = (l + r) >> 1;",
    "        build(l, mid, lson), build(mid + 1, r, rson);",
    "        pop(rt);",
    "    }",
    "    void push(int rt, int l, int r) {",
    "        if(lazy[rt] == 0) return ;",
    "        int mid = (l + r) >> 1;",
    "        lazy[lson] += lazy[rt];",
    "        lazy[rson] += lazy[rt];",
    "        sum[lson] += lazy[rt] * (mid - l + 1);",
    "        sum[rson] += lazy[rt] * (r - mid);",
    "        lazy[rt] = 0;",
    "    }",
    "    void apply(int rt, int l, int r, int v) {",
    "        lazy[rt] += v;",
    "        sum[rt] += v * (r - l + 1);",
    "    }",
    "    void update(int v, int L, int R, int l, int r, int rt) {",
    "        if(L <= l && r <= R) {",
    "            apply(rt, l, r, v);",
    "            return ;",
    "        }",
    "        int mid = (l + r) >> 1;",
    "        push(rt, l, r);",
    "        if(L > mid) {update(v, L, R, mid + 1, r, rson);}",
    "        else if(R <= mid) {update(v, L, R, l, mid, lson);}",
    "        else {",
    "            update(v, L, mid, l, mid, lson);",
    "            update(v, mid + 1, R, mid + 1, r, rson);",
    "        }",
    "        pop(rt);",
    "    }",
    "    int query(int L, int R, int l, int r, int rt) {",
    "        if(L <= l && r <= R) {",
    "            return sum[rt];",
    "        }",
    "        int mid = (l + r) >> 1, ans = 0;",
    "        push(rt, l, r);",
    "        if(L > mid) {ans += query(L, R, mid + 1, r, rson);}",
    "        else if(R <= mid) {ans += query(L, R, l, mid, lson);}",
    "        else {",
    "            ans += query(L, mid, l, mid, lson);",
    "            ans + query(mid + 1, R, mid + 1, r, rson);",
    "        }",
    "        return ans;",
    "        pop(rt);",
    "    }",
    "#undef lson",
    "#undef rson",
    "};",
    		],
    		"description": "简单线段树模板"
    	},
    	"freopen模板": {
    		"prefix": "mb_freopen",
    		"body": [
    			"#ifdef LH_LOCAL",
    "    freopen("D:/ACM/mtxt/in.txt", "r", stdin);",
    "    // freopen("D:/ACM/mtxt/out.txt", "w", stdout);",
    "#endif",
    		],
    		"description": "freopen模板"
    	},
    	"头文件完整": {
    		"prefix": "mb_headfile1",
    		"body": [
    			"#include <bits/stdc++.h>",
    "#define fi first",
    "#define se second",
    "#define o2(x) (x) * (x)",
    "#define mk make_pair",
    "#define eb emplace_back",
    "#define SZ(x) ((int)(x).size())",
    "#define all(x) (x).begin(), (x).end()",
    "#define clr(a, b) memset((a), (b), sizeof((a)))",
    "#define rep(i, s, t) for(register int i = (s), LIM=(t); i < LIM; ++i)",
    "#define per(i, s, t) for(register int i = (s), LIM=(t); i >= LIM; --i)",
    "#define GKD std::ios::sync_with_stdio(false);cin.tie(0)",
    "#define my_unique(x) sort(all(x)), x.erase(unique(all(x)), x.end())",
    "using namespace std;",
    "typedef long long LL;",
    "typedef long long int64;",
    "typedef unsigned long long uint64;",
    "typedef pair<int, int> pii;",
    "// mt19937 rng(time(NULL));//std::clock()",
    "// mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());",
    "// shuffle(arr, arr + n, rng64);",
    "inline int64 read() {",
    "    int64 x = 0;int f = 0;char ch = getchar();",
    "    while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();",
    "    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch =",
    "    getchar(); return x = f ? -x : x;",
    "}",
    "inline void write(int64 x, bool f = true) {",
    "    if (x == 0) {putchar('0'); if(f)putchar('\n');else putchar(' ');return;}",
    "    if (x < 0) {putchar('-');x = -x;}",
    "    static char s[23];",
    "    int l = 0;",
    "    while (x != 0)s[l++] = x % 10 + 48, x /= 10;",
    "    while (l)putchar(s[--l]);",
    "    if(f)putchar('\n');else putchar(' ');",
    "}",
    "int lowbit(int x) { return x & (-x); }",
    "template <class T>",
    "T big(const T &a1, const T &a2) {return a1 > a2 ? a1 : a2;}",
    "template <class T>",
    "T sml(const T &a1, const T &a2) {return a1 < a2 ? a1 : a2;}",
    "template <typename T, typename... R>",
    "T big(const T &f, const R &... r) {return big(f, big(r...));}",
    "template <typename T, typename... R>",
    "T sml(const T &f, const R &... r) {return sml(f, sml(r...));}",
    "void debug_out() { cout << '\n'; }",
    "template <typename T, typename... R>",
    "void debug_out(const T &f, const R &... r) {",
    "    cout << f << " ";",
    "    debug_out(r...);",
    "}",
    "#ifdef LH_LOCAL",
    "#define debug(...) cout << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);",
    "#else",
    "#define debug(...) ;",
    "#endif",
    "/*================Header Template==============*/",
    "const int mod = 998244353;// 998244353",
    "const int INF = 0x3f3f3f3f;",
    "int ksm(int a, int64 b, int kmod = mod) {int res = 1;for(;b > 0;b >>= 1, a = (int64)a * a % kmod) if(b &1) res = (int64)res * a % kmod;return res;}",
    "const int MXN = 2e5 + 5;",
    "",
    "int n, m;",
    "void work() {",
    "    n = read();",
    "}",
    "int main() {",
    "#ifdef LH_LOCAL",
    "    freopen("D:/ACM/mtxt/in.txt", "r", stdin);",
    "    // freopen("D:/ACM/mtxt/out.txt", "w", stdout);",
    "#endif",
    "    for(int cas = 1, tim = 1; cas <= tim; ++ cas) {",
    "        // printf("Case #%d:\n", cas);",
    "        work();",
    "    }",
    "#ifdef LH_LOCAL",
    "    cout << "time cost:" << 1.0 * clock() / CLOCKS_PER_SEC << "s" << endl;",
    "#endif",
    "    return 0;",
    "}",
    		],
    		"description": "头文件完整"
    	},
    	"头文件部分": {
    		"prefix": "mb_headfile2",
    		"body": [
    			"#include <bits/stdc++.h>",
    "using namespace std;",
    "void debug_out() { cout << '\n'; }",
    "template <typename T, typename... R>",
    "void debug_out(const T &f, const R &... r) {",
    "    cout << f << " ";",
    "    debug_out(r...);",
    "}",
    "#ifndef ONLINE_JUDGE",
    "#define debug(...) cout << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);",
    "#else",
    "#define debug(...) ;",
    "#endif",
    "typedef long long LL;",
    "bool Finish_read;",
    "inline long long Rd() {long long x = 0;Finish_read = 0;int f = 1;char ch = getchar();while (!isdigit(ch)) {if (ch == '-') f = -1;if (ch == EOF) return x;ch = getchar();}while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();x *= f;Finish_read = 1;return x;}",
    "template <class T>inline void print(T x) {if(x > 9) print(x / 10), putchar(x % 10 ^ 48);else if(x < 0) putchar('-'), print(-x);else putchar(x % 10 ^ 48);}",
    "template <class T>inline void write(T x, char c = '\n') {print(x);putchar(c);}",
    "#define read(x) x = Rd()",
    "#define read2(x, y) x = Rd(), y = Rd()",
    "#define read3(x, y, z) x = Rd(), y = Rd(), z = Rd()",
    "",
    "constexpr int mod = 998244353;",
    "constexpr int INF = 0x3f3f3f3f;",
    "constexpr int mxN = 2e5 + 5;",
    "int n, m;",
    "int ans;",
    "void prework() {",
    "    read(n);",
    "    debug(n)",
    "}",
    "void work() {",
    "    ",
    "}",
    "void finalwork() {",
    "    write(n);",
    "}",
    "int main() {",
    "    for(int Case = 1, allc = 1; Case <= allc; ++ Case) {",
    "        prework();",
    "        work();",
    "        finalwork();",
    "    }",
    "    return 0;",
    "}",
    		],
    		"description": "头文件部分"
    	},
    }
    
  • 相关阅读:
    【转】基于CNN目标检测方法(RCNN,Fast-RCNN,Faster-RCNN,Mask-RCNN,YOLO,SSD)行人检测,目标追踪,卷积神经网络
    YOLOv1_paper
    程序的编译链接过程【转】
    tensorflow-MTCNN【转】
    FaceNet实现人脸检测和识别
    ORACLE常用SQL优化hint语句
    SQL Cursor生命周期
    Hive SQL的编译过程
    深入浅出数据仓库中SQL性能优化之Hive篇
    Hive基础
  • 原文地址:https://www.cnblogs.com/Cwolf9/p/9876275.html
Copyright © 2011-2022 走看看