第14届浙江省赛By Tusimple

【网赛链接】

第14届浙江省赛By Tusimple

【A】

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
#define cle(a,val) memset(a,(val),sizeof(a))
#define SI(N) scanf(“%d”,&(N))
#define SII(N,M) scanf(“%d %d”,&(N),&(M))
#define SIII(N,M,K) scanf(“%d %d %d”,&(N),&(M),&(K))
#define rep(i,b) for(int i=0;i<(b);i++)
#define rez(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i–)
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define PU(x) puts(#x);
#define PI(A) cout<<(A)<<endl;
#define DG(x) cout<<#x<<“=”<<(x)<<endl;
#define DGG(x,y) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<endl;
#define DGGG(x,y,z) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<” “<<#z<<“=”<<(z)<<endl;
#define PIar(a,n) rep(i,n)cout<<a[i]<<” “;cout<<endl;
#define PIarr(a,n,m) rep(aa,n){rep(bb, m)cout<<a[aa][bb]<<” “;cout<<endl;}
const double EPS = 1e-9 ;
int N,a1,T;
int Kobayashi[4]={1,0,1,-1},Kscore;
int Tohru[4]={0,1,1,-1},Tscore;
int main(){
    while(~SI(N)){
        while(N–){
            SI(T);
            Kscore=0;
            Tscore=0;
            rep(i,T){
                SI(a1);
                Kscore+=Kobayashi[a1-1];
                Tscore+=Tohru[a1-1];
            }
            if(Kscore>Tscore)
                puts(“Kobayashi”);
            else if(Tscore>Kscore)
                puts(“Tohru”);
            else
                puts(“Draw”);
        }
    }
    return 0;
}

【B】

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
#define cle(a,val) memset(a,(val),sizeof(a))
#define SI(N) scanf(“%d”,&(N))
#define SII(N,M) scanf(“%d %d”,&(N),&(M))
#define SIII(N,M,K) scanf(“%d %d %d”,&(N),&(M),&(K))
#define rep(i,b) for(int i=0;i<(b);i++)
#define rez(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i–)
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define PU(x) puts(#x);
#define PI(A) cout<<(A)<<endl;
#define DG(x) cout<<#x<<“=”<<(x)<<endl;
#define DGG(x,y) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<endl;
#define DGGG(x,y,z) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<” “<<#z<<“=”<<(z)<<endl;
#define PIar(a,n) rep(i,n)cout<<a[i]<<” “;cout<<endl;
#define PIarr(a,n,m) rep(aa,n){rep(bb, m)cout<<a[aa][bb]<<” “;cout<<endl;}
const double EPS = 1e-9 ;
const int maxn=20000+10;
int T,N,fk,Orz,flag,cnt;
int score[maxn],scomp[maxn];
int main(){
    while(~SI(T)){
        while(T–){
            fill(score,score+4000,0);
            Orz=flag=0;
            SI(N);
            if(N>13 || N<10){
                rep(i,N){
                    SI(fk);
                }
                puts(“No”);continue;
            }
            rep(i,N){
                SI(fk);
                if(fk<=0){
                    flag=1;
                }else{
                    score[fk]++;
                }
                scomp[i]=fk;
            }
            if(flag){
                puts(“No”);
            }else{
                if(score[1]<2){
                    puts(“No”);
                    continue;
                }else{
                    sort(scomp,scomp+N);
                    rez(i,1,N-2){
                        if(scomp[i]-scomp[i-1]>2){
                            puts(“No”);
                            flag=1;
                            break;
                        }
                    }
                    if(!flag) puts(“Yes”);
                }
            }
        }
    }
    return 0;
}

【C】

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
#define cle(a,val) memset(a,(val),sizeof(a))
#define SI(N) scanf(“%d”,&(N))
#define SII(N,M) scanf(“%d %d”,&(N),&(M))
#define SIII(N,M,K) scanf(“%d %d %d”,&(N),&(M),&(K))
#define rep(i,b) for(int i=0;i<(b);i++)
#define rez(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i–)
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define PU(x) puts(#x);
#define PI(A) cout<<(A)<<endl;
#define DG(x) cout<<#x<<“=”<<(x)<<endl;
#define DGG(x,y) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<endl;
#define DGGG(x,y,z) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<” “<<#z<<“=”<<(z)<<endl;
#define PIar(a,n) rep(i,n)cout<<a[i]<<” “;cout<<endl;
#define PIarr(a,n,m) rep(aa,n){rep(bb, m)cout<<a[aa][bb]<<” “;cout<<endl;}
const double EPS = 1e-9 ;
int T,n,q,c;
map<string,int> mp;
map<string,int>::iterator ite;
map<int,vector<string> > res;
string st;

inline int readt(int N){
    int ans=0,tit;
    rep(i,N){
        SI(tit);
        ans+=(1<<N-i-1) & (tit<<N-i-1);
    }
    return ans;
}

int main(){
    SI(T);
    while(T–){
        //测试数据可能出现重复的名字和情况,所以要初始化
        mp.clear();
        res.clear();
        SII(n,q);
        SI(c);
        rep(i,c){
            cin>>st;
            mp[st]=0;
        }
        rep(i,q){
            int nu;
            SI(nu);
            rep(j,nu){
                cin>>st;
                mp[st]+=(1<<q-i-1);
            }
        }
        for(ite=mp.begin();ite!=mp.end();ite++){
            res[ite->second].push_back(ite->first);
        }
        rep(i,n){
            int index=readt(q);
            if(res.find(index)==res.end()){
                puts(“Let’s go to the library!!”);
            }else{
                vector<string>& t=res[index];
                if(t.size()>1){
                    puts(“Let’s go to the library!!”);
                }else{
                    cout<<t[0]<<“\n”;
                }
            }
        }
    }
    return 0;
}

【D】

因为样例用的是m=3…所以我就一直卡在z>=3……然后比赛结束以后发现了…好亏啊

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
#define cle(a,val) memset(a,(val),sizeof(a))
#define SI(N) scanf(“%d”,&(N))
#define SII(N,M) scanf(“%d %d”,&(N),&(M))
#define SIII(N,M,K) scanf(“%d %d %d”,&(N),&(M),&(K))
#define rep(i,b) for(int i=0;i<(b);i++)
#define rez(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i–)
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define PU(x) puts(#x);
#define PI(A) cout<<(A)<<endl;
#define DG(x) cout<<#x<<“=”<<(x)<<endl;
#define DGG(x,y) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<endl;
#define DGGG(x,y,z) cout<<#x<<“=”<<(x)<<” “<<#y<<“=”<<(y)<<” “<<#z<<“=”<<(z)<<endl;
#define PIar(a,n) rep(i,n)cout<<a[i]<<” “;cout<<endl;
#define PIarr(a,n,m) rep(aa,n){rep(bb, m)cout<<a[aa][bb]<<” “;cout<<endl;}
const double EPS = 1e-9 ;

struct Star{
    int left,right;
    bool operator<(const Star MM) const{
        return left<MM.left;
    }
}A[500],B[500];
int n,m,x,y,T,s,e;

int main(){
    SI(T);
    while(T–){
        SII(n,m);SII(x,y);
        rep(i,x){
            SII(s,e);
            A[i].left=s;
            A[i].right=e;
        }
        rep(i,y){
            SII(s,e);
            B[i].left=s;
            B[i].right=e;
        }
        sort(A,A+x);
        sort(B,B+y);
        int ans=0;
        rep(i,x){
            s=A[i].left;
            e=A[i].right;
            int z=0;
            rep(j,y){
                if(B[j].left>A[i].right) break;
                z+=(min(B[j].right,A[i].right)-max(A[i].left,B[j].left)+1);
                    if(z>=m){
                        ans+=z-m+1;
                        z=0;
                    }else{
                        z=0;
                    }
            }
        }
        printf(“%d\n”,ans);
    }
    return 0;
}