Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

勉强水过~~~

Posted by wenhaooo at 2013-09-01 19:56:05 on Problem 1013
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int t,s[13],la,lb;
    char a[13],b[13],c[10];
    cin>>t;
    while(t--)
    {
        memset(s,-1,sizeof(s));
        for(int i=0; i<3; i++)
        {
            scanf("%s %s %s",a,b,c);
            la=strlen(a),lb=strlen(b);
            if(strcmp(c,"even")==0)
            {
                for(int j=0; j<la; j++)
                    s[a[j]-'A']=1;
                for(int j=0; j<lb; j++)
                    s[b[j]-'A']=1;
            }
            else if(strcmp(c,"up")==0)
            {
                for(int j=0; j<la; j++)
                    if((s[a[j]-'A']<=0&&s[a[j]-'A']!=-1)||s[a[j]-'A']==1)
                        s[a[j]-'A']=1;
                    else if(s[a[j]-'A']>=2)
                        s[a[j]-'A']+=2;
                    else
                        s[a[j]-'A']=2;
                for(int j=0; j<lb; j++)
                    if(s[b[j]-'A']>=2||s[b[j]-'A']==1)
                        s[b[j]-'A']=1;
                    else if(s[b[j]-'A']<=0&&s[b[j]-'A']!=-1)
                        s[b[j]-'A']-=2;
                    else
                        s[b[j]-'A']=0;
            }
            else if(strcmp(c,"down")==0)
            {
                for(int j=0; j<la; j++)
                    if(s[a[j]-'A']>=2||s[a[j]-'A']==1)
                        s[a[j]-'A']=1;
                    else if(s[a[j]-'A']<=0&&s[a[j]-'A']!=-1)
                        s[a[j]-'A']-=2;
                    else
                        s[a[j]-'A']=0;
                for(int j=0; j<lb; j++)
                    if((s[b[j]-'A']<=0&&s[b[j]-'A']!=-1)||s[b[j]-'A']==1)
                        s[b[j]-'A']=1;
                    else if(s[b[j]-'A']>=2)
                        s[b[j]-'A']+=2;
                    else
                        s[b[j]-'A']=2;
            }
        }
        int min=s[0],max=s[0],mini=0,maxi=0;
        for(int i=0; i<13; i++)
        {
           if(s[i]<min&&s[i]!=-1)
           {
               min=s[i];
               mini=i;
           }
           if(s[i]>max&&s[i]!=-1)
           {
               max=s[i];
               maxi=i;
           }
        }
        //cout<<max<<" "<<min<<endl;
        if(max-2<=0-min)
        {
            printf("%c is the counterfeit coin and it is light.\n",mini+'A');
            continue;
        }
        else
        {
            printf("%c is the counterfeit coin and it is heavy.\n",maxi+'A');
            continue;
        }
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator