码风

· · 个人记录

我的码风前后经历了两次变革:

1. \quad 2020 \sim 2023.8.1

2. \quad 2023.8.1 \sim today

之前的码风:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
ll n,a[maxn];
int main() {
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    for(int i=2;i<=n;++i){
        cout<<a[i];
    }
    return 0;
}

调用函数:

int gcd(int a,int b){

}
int c=gcd(a,b);

快读模板:

template<typename T>inline void read(T &x) {
    x=0;
    bool flag=false;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        flag=ch=='-'?true:false;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<3)+(x<<1)+(ch&15);
        ch=getchar();
    }
    if(flag){
        x=-x;
    }
}

看着确实很挤,找错也不容易。

现在的码风:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const double pi = 3.1415926535897932385;
typedef long long ll;
typedef pair<int,int> Pr;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, eps=1e3+10, maxn=1e6+10;
template <typename T> inline void read(T &x) {
    x = 0;
    bool flag = false;
    char ch = getchar();
    while (ch < '0' || ch > '9') flag = ch == '-' ? true : false, ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
    if(flag) x = -x;
}
template <typename T> inline void write(T x) {
    if(x<0) {
        putchar('-');
        x = -x;
    }
    if(x>9) write(x / 10);
    putchar(x % 10 + '0');
}
int n, m, a[1005][1005];
unordered_map<string, vector <int> > mp;
int main() {
    read(n), read(m);
    string s;
    s.resize(m);
    for (int i = 1;i <= m; i++)
        for (int j = 1;j <= n; j++)
            cin >> a[i][j];
    for (int i = 1;i <= n; i++) {
        for (int j = 1;j <= m; j++) s[j-1] = a[j][i];
        mp[s].push_back(i);
    }
    pair<int, int> p = make_pair(n+1, n+1);
    for(auto &it : mp)
        if(it.second.size() >= 2) p = min(p, make_pair(it.second[0], it.second[1]));
    if(p.first == n+1) puts("-1");
    else printf("%d %d", p.first, p.second);
    return 0;
}

我个人认为现在的码风比之前的好看很多。