题解 CF409A 【The Great Game】

无可否认,这是一道模拟水题,题目说什么照做就行了~

既然题目说,"[]"是布"()"是石头"8<"是剪刀,那么,仔细想一想,只需要判断"["、"("和"8"就可以了,因为没有重复的标识符。

我的做法是,分别把三个标识符存为数字1、2、3,并逐一进行比较。

AC代码:

Var x,y:ansistring;
    c,d:array[1..10000] of 0..2;
    a,b,l,i,j:longint;
Begin
        readln(x);
        readln(y);//输入两个字符串
        l:=length(x);//取字符串的长度

        //以下部分为将标识符分别转成1、2、3
        j:=0;
        for i:=1 to l do
        Begin
                //判断
                if x[i]='[' then
                Begin
                        j:=j+1;
                        c[j]:=0;
                end
                else if x[i]='(' then
                Begin
                        j:=j+1;
                        c[j]:=1;
                end
                else if x[i]='8' then
                Begin
                        j:=j+1;
                        c[j]:=2;
                end;
        end;

        j:=0;
        for i:=1 to l do
        Begin
                //判断
                if y[i]='[' then
                Begin
                        j:=j+1;
                        d[j]:=0;
                end
                else if y[i]='(' then
                Begin
                        j:=j+1;
                        d[j]:=1;
                end
                else if y[i]='8' then
                Begin
                        j:=j+1;
                        d[j]:=2;
                end;
        end;

        for i:=1 to l div 2 do //因为长度是首表示符的2倍所以要除以2
        Begin
                if c[i]<>d[i] then
                Begin
                        //判断
                        if (c[i]=0) and (d[i]=1) then
                        Begin
                                a:=a+1;
                        end
                        else if (c[i]=1) and (d[i]=2) then
                        Begin
                                a:=a+1;
                        end
                        else if (c[i]=2) and (d[i]=0) then
                        Begin
                                a:=a+1;
                        end
                        else b:=b+1;
                end;
        end;
        if a>b then write('TEAM 1 WINS')
        else if a<b then write('TEAM 2 WINS')
        else write('TIE');
end.    

猜你喜欢

转载自blog.csdn.net/cpongo11/article/details/99674883
今日推荐