#32963:


11131039@stu.tshs.tp.edu.tw (二孝25林孟希)

學校 : 不指定學校
編號 : 201083
來源 : [36.227.70.244]
最後登入時間 :
2024-05-22 06:16:38
h026. 202001_1 猜拳 -- 2020年1月APCS | From: [36.225.121.25] | 發表日期 : 2022-11-19 21:27

#include<iostream>
using namespace std;
int main(void)
{
    int first,n,round=0,flag;
    cin>>first>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    while(true)
    {
        round=round+1;
        if(first==0)
        {
            if(a[0]==0)
            {
                flag=1;
                round=round+1;
                cout<<first<<" ";
                first=0;
            }
            else if(a[0]==2)
            {
                flag=0;
                cout<<first<<" ";
                break;
            }
            else if(a[0]==5)
            {
                flag=2;
                cout<<first<<" ";
                break;
            }
        }
        else if(first==2)
        {
            if(a[0]==0)
            {
                flag=2;
                cout<<first<<" ";
                break;
            }
            else if(a[0]==2)
            {
                flag=1;
                round=round+1;
                cout<<first<<" ";
                first=2;
            }
            else if(a[0]==5)
            {
                flag=0;
                cout<<first<<" ";
                break;
            }
        }
        else if(first==5)
        {
            if(a[0]==0)
            {
                flag=0;
                cout<<first<<" ";
                break;
            }
            else if(a[0]==2)
            {
                flag=2;
                cout<<first<<" ";
                break;
            }
            else if(a[0]==5)
            {
                flag=1;
                round=round+1;
                cout<<first<<" ";
                first=5;
            }
        }
        for(int i=1;i<n;i++)
        {
            if(first==0)
        {
            if(a[i]==0)
            {
                flag=1;
                round=round+1;
                cout<<first<<" ";
                if(a[i-1]==a[i])
                {
                    first=5;
                }
                else if(a[i-1]!=a[i])
                {
                    first=0;
                }
            }
            else if(a[i]==2)
            {
                flag=0;
                cout<<first<<" ";
                break;
            }
            else if(a[i]==5)
            {
                flag=2;
                cout<<first<<" ";
                break;
            }
        }
        else if(first==2)
        {
            if(a[i]==0)
            {
                flag=2;
                cout<<first<<" ";
                break;
            }
            else if(a[i]==2)
            {
                flag=1;
                round=round+1;
                cout<<first<<" ";
                if(a[i-1]==a[i])
                {
                    first=0;
                }
                else if(a[i-1]!=a[i])
                {
                    first=2;
                }
            }
            else if(a[i]==5)
            {
                flag=0;
                cout<<first<<" ";
                break;
            }
        }
        else if(first==5)
        {
            if(a[i]==0)
            {
                flag=0;
                cout<<first<<" ";
                break;
            }
            else if(a[i]==2)
            {
                flag=2;
                cout<<first<<" ";
                break;
            }
            else if(a[i]==5)
            {
                flag=1;
                round=round+1;
                cout<<first<<" ";
                if(a[i-1]==a[i])
                {
                    first=2;
                }
                else if(a[i-1]!=a[i])
                {
                    first=5;
                }
            }
        }
        }
        break;
    }
    cout<<": ";
    if(flag==0)
    {
        cout<<"Won at round "<<round;
    }
    else if(flag==2)
    {
        cout<<"Lost at round "<<round;
    }
    else if(flag==1)
    {
        cout<<"Drew at round "<<round-1;
    }
}
 
ZeroJudge Forum