CSP S 2021 第二轮 YN 选手经典代码大展

· · 个人记录

前言:

CSP J/S 2021 刚刚逝去,每位选手都有自己独特的代码,本展即旨在对 YN 选手的经典代码进行展示,对于入展的代码及其归属选手,并无故意冒犯之意,如有介意,可私信联系以将其代码下展。

说明:

本展所有代码均采用标称+代码块的形式进行展示,其中对于代码块,第一行标记准考证号,并对准考证号进行有效数字隐末位处理,以 * 替代。例:YN-00001 示为 YN-0000*YN-00012 示为 YN-0001*YN-00123 示为 YN-0012*

经典代码大展:

中英结合起变量名人

YN-0000*

int nei[100000][2],wai[100000][2];
int n,m1,m2,i,t,j,h,akali,lishuangle;   
int neizong=0,waizong=0,zongans=0;
int nlastgo=0,wlastgo=0,zonglastgo=0;
int nnei=0,nwai=0;

多重经典•注释人&gets()人&样例人

YN-0000*

#include<bits/stdc++.h>
using namespace std;
int main()
{
//  freopen("palin.in","r",stdin);
//  freopen("palin.out","w",stdout);
    int t,n,m;
    char a[500020],b[500020];
    cin>>t;
    cin>>n;
    gets(a);
    cin>>m;
    gets(b);
    if(t==2)
        cout<<"LRRLLRRRRL"<<endl<<"-1";
    else
    {
        cout<<-1<<endl;
        cout<<-1<<endl;
        cout<<"LLLLLLLLLLLLRLLLLLLLRRLRLLLLLLLLLLLLLLRLLLRRRLRLRLLRLLLLRRLLLLLRLLLLLRLLRRLLLLLLLLLLRRLLLLLLLRLLLLLLLRLRLLLRRRLRRLLRLLLL"<<endl;
        cout<<-1<<endl;
        cout<<"RRRRRRRRRRRRRRRRRRRRRRRRRRRRLRRRRRRRRRRLLLLLLLRRLLLLLLLRRLLLLLRRRLLLLLLLLLRRRLRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLRRLLLRRLLRRLLLLLLLRLLLLLLLLLLLLRLLLLRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLLLRRRRLLLLLLLLLRLLRRRLLLLLLRLLLLLRLLLL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLLLLLLLLLLLLLLLLLLLLLLLLLLRLLLLLLLLLLLLLLLLLLRRLLLLRLLLRLLLLRRRRLRRLLLRRRLLLLLLRRLLRRRRLRRRRRRRRRLLRRRRLRRRRRRRRLLRRRRLLLLLRRRRRRLLLRRRLRRLLLRLLLLRLRRRRLRRLLLL"<<endl;
        cout<<-1<<endl<<-1<<endl<<-1<<endl;
        cout<<"LRLLLRRRRRLLLLRRRRLLLRRLRRLLLLLRLLRLLLLLLRLLRLLLRLLLLRRLLLLLRLLLLLLRRLLLLLLLLLLL"<<endl;
        cout<<-1<<endl;
        cout<<"LRRLRLLRRLLRLRLRLLLLRRRLLRRLLRRRRLLLLLRL"<<endl;
        cout<<-1<<endl<<-1<<endl<<-1<<endl;
        cout<<"LRLRRLLRRLLLLRLRRLRRRRRRLLLRRRLLLRLLLRRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLRLRLRLLRLLLLLRRLLLRLLLLLLLLRRLLLLLRRLL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LRLLRRLLRRRRRRRRLRRRRLRRRRLRLRLLRRRRRRRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLLLLLLRLLLLLRRRLLRLLLLRRRRLLLLLLRLRRRRLLLLLLLLLLLLLLLLLLLRLRRLLLLLLLLLLLRLLLLLL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLRLLRLLLLLLLLRLLLLLLLRRLRRLRLRRRRLLRRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLLLLRRRRLRLLRLLRLLLLRLLRLLLLLLLLLRLLLLLLLRLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLRLRRRLLLRRRRLLLLLLRLLLLRRRRRLLLLLLRRRLLLLRLLRRLLLRLLLLLRRLLLLLLLRLLLLLLRLRRLRLLLLRRRLRLLLRLRRLLRLRRRRLRRRLLRLRRLLRLRRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LRLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL"<<endl;
        cout<<-1<<endl;
        cout<<"LLRRRRRRRRRRRRRRRRRRRRRLRRRRLRRLRRRRLLRLLLLRLLLLLLLLLRLLLLLLLLRRLRRLLLLLLLRLLLLL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLRLLRRRRRLLLRLLLLLRRRRLLRRRRLLRRLLLRRLLLLLLLLLRRRRLLLLLLLRRLLLLLLRRRRLRLLRLLLL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLLLLLLLLLRLLLRLLLLLLLLLRLLLLRLLLLRRLLLLRRRLRRRLRRRRRLRRLLLRRLLLLLRRRRLLLLRRLLL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LRRRRRRLLRRRRRRRRRRRRRRRRRRRLRLRRRRLLRRL"<<endl;
        cout<<-1<<endl<<-1<<endl<<-1<<endl;
        cout<<"LRRRRRRRRRRRRLRRRRRLRRLRRRRRRRRRRRRRRLLL"<<endl;
        cout<<-1<<endl<<-1<<endl<<-1<<endl;
        cout<<"LLLRLLLLLRLLRRLLLLLLRRLLLLLRLLLLRRRLLLRLRRLRRRRLRRRRRRRRRRRRRLRLRRLRRRRRRRRLLRRL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLLLLLLLLLLLLLLLLLLLLLLLLRLLLLRLLRLRLLLLLLLLLLRRLRLRRLLRRLRRLLRLLLRLLLLRLLLLLRL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLLLRLRLLLRLLLLLLRLLLLLLLLLLLLLLLLRLLRL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LLLRLRLLRRRRRRRRRRLRRRRRRRRLRRLLRRRLLRRLLLLLRRRRRRRRLLLLRRRLLLRRRRRRRRRRRRLRLLRL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLLRRLRRRRLRLRRRLLLLRLLRRLLRRLRLRRLRRLLLRLRRRRRRRLLLRRLRRLLRRRLRRRRLRRRLLLLLRRL"<<endl;
        cout<<-1<<endl<<-1<<endl<<-1<<endl;
        cout<<"RRRRRRLRRRRLRRRRLLRRRRLRRRRLRRLRRRRLRRRLLLLRLLRLLLLLLLLLLLLLRLLLLLRLLRLLLLLLLRLLLLLLLRRRLLLLRLLLLLLLLLRLLLLLLLLLLLLRLLLL"<<endl;
        cout<<-1<<endl<<-1<<endl;
        cout<<"LRLRLLLLRRLRRRLLRLLLLRLLLLLLLRRRLLLRRLLL"<<endl;
        cout<<-1<<endl;
        cout<<"LLLLRRLLRRLLLRLLLLLLLLLLLLLRLLLRLLLLRLLLLLLLRLRLLLLRRLLLLLLRRLLLLLLLLRLLLLLLLLLL"<<endl<<-1<<endl<<-1;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
 }

ab人

YN-0000*

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;

    cout<<5;
    return 0;
}

我也有cpp人

YN-0001*

(traffic.cpp内容如下:)

(是的,一无所有。仅建了cpp文件,里面空空如也。)

判断人

YN-0001*

#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("airport.in","r",stdin);
    freopen("airport.out","w",stdout);
    int n,k;
    char S[10000];
    cin>>n;
    cin>>k;
    for(int i=1;i<=n;i++)
        cin>>S[i];
    if(n==7&&k==3)
        if(S==(*??*??)
            cout<<"5";
    if(n==10&&k==2)
        if(S==???(*??(?))
            cout<<"19";
    if(n==100&&k==18)
        if(S==?*?????)?????*????????*??(*???????*????????????*???*?????*?????*??????*****??*??????????*???????????) 
            cout<<"860221334";
    if(n==500&&k==57)
        if(S==????*???***??*?????(????????*?**??????(??????????*??**??*?????????????????????*??????????*?????**????*?????????????????????*?????????????????????????????????*)*?????*????*??*???????????*????????????????*?????*?????*?*???)?????????*????*???*??????????????*???????????????????????*?????*?????*????????????????**??*?????????*?????????????????*??**?????????????*????**?*??*??*??????????*???*??**?(?*???????????????????????????**???????????***??????????*???????*)*???*?????????????????????*????????*????*?)
            cout<<"546949722";
    return 0;
}

我也进行了文件操作人

YN-0001*

#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("airport.in","r",stdin);
    freopen("airport.out","w",stdout);

    return 0;
}

高端文件操作人&文件名人

YN-0001*

#include<bits/stdc++.h>
using namespace std;
int m1[1001][1001],m2[1001][1001],cnt=0;
int main(){
freopen("airsport.in","r",stdin);
freout("airsport.out","w",stdout);
    int a,n,m1,m2;
    cin>>a>>n>>m1>>m2;
    for(int i=0;i<=n;i++){
        if(m1>m2){
            m2=m1;
            cnt=cnt+1;
        }
    }
    if(a==3){
        cout<<7;
    }
    if(a==2){
        cout<<4;
    }
    if(a==10){
        cout<<32;
    }

freopen("airsport.in",work);
freout("airsport.out",work);
return 0;
}

代码共用但没完全共用人

YN-0003*
(把T2代码贴到了T3、T4,并改了一下文件名)

#include <bits/stdc++.h>
using namespace std;
int n,m,hj=0,jd=0,jx[501],js=0,z=0,jj=0,k=0,r=0;
int q=0;
char a[501],b[4]={'0','*','(',')'};
int search(int x){
    if(x==js){
        jj=0;
        jd=0;
        k=0;
        q=0;
        r=0;
        if(hj!=0){
            jj=1;
        }
        for(int i=0;i<n;i++){
            if(a[i]=='('){
                q++;
                jd=0;
                k=1;
                r=0;
            }
            if(a[i]==')'){
                if((k==1)&&(q>1)){
                    jj=1;
                    break;
                }
                if(q!=0)
                    q--;
                k=0;
                jd=0;
                r=0;
            }
            if(a[i]=='*'){
                k=0;
                jd++;
                r=1;
            }
            if(jd>m){
                jj=1;
                break;
            }
        }
        if((jj==0)&&(q==0)&&(r==0)){
            for(int j=0;j<n;j++){
                cout<<a[j];
            }
            cout<<endl;
            z++;
        }   
        return 0;
    }
    for(int i=1;i<=3;i++){
        a[jx[x]]=b[i];
        if(i==2){
            hj++;
        }
        if(i==3){
            hj--;
        } 
        search(x+1);
        if(i==2){
            hj--;
        }
        if(i==3){
            hj++;
        } 
    }
}
int main(){
    freopen(" traffic.in","r",stdin);
    freopen(" traffic.out","w",stdout);
    cin>>n>>m;
    cin>>a;
    for(int i=0;i<n;i++){
        //cin>>a[i];
        //scanf("%c",&a[i]);
        if(a[i]=='('){
            hj++;
            q=1;
        }
        if(a[i]==')'){
            hj--;
            q=0;
        } 
        if(a[i]=='?'){
            jx[js]=i;
            js++;
        }
    }
    search(0);
    cout<<z;
    return 0; 
    fclose(stdin);
    fclose(stdout);
}

经典•文件名人

YN-0003*

freopen("airsport.in","r",stdin);
freopen("airsport.out","w",stdout);

幸运数字人

YN-0003*

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

int main(){
    freopen("bracket.in","r",stdin);
    freopen("bracket.out","w",stdout);
    int a,b;
    string s;
    cin>>a>>b>>s;

    int c;
    c=(a+b)%13;

    cout<<c;
    return 0;
}

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

int a[10000][10000];

int main(){
    freopen("traffic.in","r",stdin);
    freopen("traffic.out","w",stdout);
    int n,m,t;
    cin>>n>>m>>t;
    for(int i=0;i<(n-1);i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<(m-1);j++){
            cin>>a[i][j];
        }
    }
    int sum;
    sum=n+m+t;
    sum=sum%13;
    cout<<sum;
    return 0;   
}

经典•忘删数字人

YN-0004*

freopen("airport3.in","r",stdin);
freopen("airport.out","w",stdout);

深情•表白人:

YN-0004*
(plain.cpp)

#include<iostream>
using namespace std;
int main(){
    printf("i love u deeplt\njust my love into the sea~~\ndo you understand?\nmy only ba~by~");
    return 0;
}
//i

不要你的输入人

YN-0004*
(T1,T2,T3,T4同法,输入一数,又重新赋一值输出)

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

int a[100005];
int main(){
    freopen("airport","r",stdin);
    freopen("airport","w",stdout);

    int c=0;
    scanf("%d",&c);
    c=7;
    printf("%d",c);

    fclose(stdin);
    fclose(stdout);
    return 0;
} 

高端骗分人

YN-0004*

#include<iostream>

using namespace std;

int main(){
    cout<<-1; 

    return 0;
}

经典•ans人

YN-0004*

freopen("airport.in","r",stdin);
freopen("airport.ans","w",stdout);

输样例也懒得输人

YN-0005*
(cout<<;)

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    freopen("traffic.in","r",stdin);
    freopen("traffic.out","w",stdout);
    int t,n,m;
    cin>>t>>n>>m;
    int a[510][510];
    int b[510][510];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            cin>>b[i][j];
        }
    }
    if(t==2&&n==3&&m==1)
    {
        cout<<12;
    }
    if(t==18&&n==18&&m==5)
    {
        cout<<;
    }if(t==100&&n==95&&m==5)
    {
        cout<<;
    }
    if(t==98&&n==100&&m==25)
    {
        cout<<;
    }
    else
    {
        cout<<;
    }
}

多重经典•忘删数字人&注释了但未完全注释人&样例人

YN-0005*

#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    freopen("traffic2.in","r",stdin);
    //freopen("traffic.out","w",stdout);
    int n,m,T;
    cin>>n>>m>>T;
    if(n==2 && m==3 && T==1){
        cout<<12;
    }
    if(n==18 && m==18 && T==5665097){
        cout<<9184175<<endl;
        cout<<181573<<endl;
        cout<<895801<<endl;
        cout<<498233<<endl;
        cout<<0<<endl;
    }
    if(n==100 && m==95 & T==565852){
        cout<<5810299<<endl;
        cout<<509355<<endl;
        cout<<1061715<<endl;
        cout<<268217<<endl;
        cout<<572334<<endl;
    }
    if(n==98 && m==100 && T==25102770){
        cout<<0<<endl;
        cout<<2473<<endl;
        cout<<355135<<endl;
        cout<<200146<<endl;
        cout<<41911<<endl;
        cout<<441622<<endl;
        cout<<525966<<endl;
        cout<<356617<<endl;
        cout<<575626<<endl;
        cout<<652280<<endl;
        cout<<229762<<endl;
        cout<<234742<<endl;
        cout<<3729<<endl;
        cout<<272817<<endl;
        cout<<244135<<endl;
        cout<<597644<<endl;
        cout<<2217<<endl;
        cout<<197078<<endl;
        cout<<534143<<endl;
        cout<<70150<<endl;
        cout<<91220<<endl;
        cout<<521483<<endl;
        cout<<180252<<endl;
        cout<<72966<<endl;
        cout<<1380<<endl;
    }

    return 0;
}

文件名多敲空格人

YN-0005*

freopen(" palin.in","r",stdin);
freopen("palin.out","w",stdout);

注释风趣人

YN-0008*
(……省略部分代码)

……
#define PROB "airport" //不要忘记删除数字 
……
if(vis[e[i2].id])//完了,码风乱了 
……
ifp=fopen(PROB ".in","r");
……
    return 0;
}
//#include<bits/stdc++.h>
//还是想要柠檬,,, 
/***
先打个暴力?
感觉像经典问题
1e5 O(nsqrtn)最多

想模拟退火 

考虑两边分别不严格地满足单调性? //吗 
抵达、离开时刻非有序!!! 
先退火要不 O(kn)

我是sb,打了3.5h错误暴力 
***/

随机人

YN-0009*

#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("bracket.in","r",stdin);
    freopen("bracket.out","w",stdout);
    int n;
    srand(time(0));
    n=rand();
    n%=1000;
    cout<<n; 
    return 0;
} 

经典•忘删数字人

YN-0010*

freopen("airport3.in","r",stdin);
freopen("airport3.out","w",stdout);

忘删数字但未完全忘删人

YN-0010*

freopen("traffic1.in","r",stdin);
freopen("traffic.out","w",stdout);

看到了这里,相信部分代码使您一乐,亦或使您对他人之码有所鉴之。
同时,如有更多需求,可到此导航查看更多地区的代码大展。

文末,念在企鹅整理的辛苦,动动您的小手点个赞支持一下呗~