洛谷 P1328 生活大爆炸版石头剪刀布 模拟

很简单
Code:

#include<cstdio>
#include<queue>
using namespace std;
queue<int>A;
queue<int>B;
int n;
int a,b;
void input(){
    scanf("%d",&n);
    scanf("%d%d",&a,&b);
    for(int i=1;i<=a;i++){
        int v;
        scanf("%d",&v);
        A.push(v);
    }
    for(int i=1;i<=b;i++){
        int v;
        scanf("%d",&v);
        B.push(v);
    }
}
int judge_A(int v1,int v2){
    if(v1==v2)return 0;
    if(!v1){
       if(v2==1||v2==4)return 0;
       return 1;
    }
    if(v1==1){
        if(v2==2||v2==4)return 0;
        return 1;
    }
    if(v1==2){
        if(!v2||v2==2||v2==3)return 0;
        return 1;
    }
    if(v1==3){
        if(!v2||v2==1)return 0;
        return 1;
    }
    if(v1==4){
        if(v2==2||v2==3)return 0;
        return 1;
    }
}
int main(){
    input();
    int tot_a=0,tot_b=0;
    for(int i=1;i<=n;i++){
        int v1=A.front();
        int v2=B.front();
        tot_a+=judge_A(v1,v2);
        tot_b+=judge_A(v2,v1);
        A.pop();
        B.pop();
        A.push(v1);
        B.push(v2);
    }
    printf("%d %d\n",tot_a,tot_b);
}

猜你喜欢

转载自blog.csdn.net/liyong1009s/article/details/82227529
今日推荐