一些模板

· · 个人记录

1. main模板

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

signed main(){

    return 0;
}

2. solve模板

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

void solve(){

}
signed main(){
    int T = 1;

    while(T--){
        solve();
    }
    return 0;
}

3. read模板

注:仅限非负数!

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

inline int read(){
    int x=0; char s=getchar();
    while(!isdigit(s)) s=getchar();
    while(isdigit(s)) x=(x<<1)+(x<<3)-48+s, s=getchar();
    return x;
}

void solve(){

}
signed main(){
    int T = 1;

    while(T--){
        solve();
    }
    return 0;
}

4. 随机数函数

注:vector 随机打乱和生成随机数

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

random_device rvm;
mt19937 rv(rvm());

/*
随机打乱 vector :
random_device name_4;
mt19937 name_5(name_4());

使用: `shuffle(vector_name.begin(), vector_name.end(), name_5);`
*/

inline int read(){
    int x=0;char c=getchar(),cc=' ';
    while(!isdigit(c)) cc=c,c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+c-'0',c=getchar();
    return cc=='-'?-x:x;
}

signed main(){
    unsigned seed = chrono::system_clock::now().time_since_epoch().count();
    mt19937 rdm(seed);

    // 生成种子:`unsigned name_1 = chrono::system_clock::now().time_since_epoch().count();`
    // 函数: `mt19937 name_2(name_1);`
    // 范围: `uniform_int_distribution<> name_3(下限, 上限);`
    // 生成: `name_3(name_2);`

    uniform_int_distribution<> n_dist(1, 1e5);
    int n = n_dist(rdm);



    return 0;
}