zoj_1184

发现外面风好大哦,木有带衣服怎么办委屈 发现一课也蛮冷的啊,一个人躲在个偏僻的课室里。。突然好想回家啊~等寒假喽,该做的事还很多呢,ACM也依旧菜得要命,要变强就要不断努力。加油~

/*
zoj_1184    模拟
简单题,一开始没想太多就写,完全模拟错了。
后来改成了逐层筛选,顺利的过了。
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
using namespace std;
int light[15];
int heavy[15];

int main()
{
    int T,i,j;
    string left,right,re;
    cin>>T;
    while( T-- )
    {
        memset( light,0,sizeof(light) );
        memset( heavy,0,sizeof(heavy) );
        for( i=1;i<=3;i++ )
        {
            cin>>left>>right>>re;
            if( re=="even" )
            {
                for( j=0;j<left.size();j++ )
                {
                    light[ left[j]-'A' ]=4;
                    heavy[ left[j]-'A' ]=4;
                }
                for( j=0;j<right.size();j++ )
                {
                    light[ right[j]-'A' ]=4;
                    heavy[ right[j]-'A' ]=4;
                }
                for( j=0;j<12;j++ )
                {
                    if( light[j]==i-1 )
                        light[j]=i;
                    if( heavy[j]==i-1 )
                        heavy[j]=i;
                }
            }
            else if( re=="up" )
            {
                for( j=0;j<left.size();j++ )
                {
                    if( heavy[ left[j]-'A' ]==i-1)
                        heavy[ left[j]-'A' ]=i;
                }
                for( j=0;j<right.size();j++ )
                {
                    if( light[ right[j]-'A' ]==i-1 )
                        light[ right[j]-'A' ]=i;
                }
            }
            else
            {
                for( j=0;j<left.size();j++ )
                {
                    if( light[ left[j]-'A' ]==i-1 )
                        light[ left[j]-'A' ]=i;
                }
                for( j=0;j<right.size();j++ )
                {
                    if( heavy[ right[j]-'A' ]==i-1 )
                        heavy[ right[j]-'A' ]=i;
                }
            }
        }
        for( i=0;i<=11;i++ )
        {
            if( heavy[i]==3 )
            {
                cout<<char(i+'A')<<" is the counterfeit coin and it is heavy.\n";
                break;
            }
            if( light[i]==3 )
            {
                cout<<char(i+'A')<<" is the counterfeit coin and it is light.\n";
                break;
            }
        }
    }
    return 0;
}


你可能感兴趣的:(String,UP)