天天看點

HDU 1073 Online Judge water~~~

題目位址: http://acm.hdu.edu.cn/showproblem.php?pid=1073

沒事刷刷水題~~~

關鍵是控制好每個字元。

AC代碼:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std;

typedef long long LL;
const int N=5222;
const LL II=1000000007;
const double PI=3.141592653;

char s1[100][N],s2[100][N];
int i1,i2;

int xiaohao()
{
    int i,j;
    if(i1==i2)
    {
        int flag=0;
        for(i=0;i<i1;i++)
            if(strcmp(s1[i],s2[i])!=0)
            {
                flag=1;break;
            }
        if(flag==0)
            return 0;
    }
    string x1="",x2="";
    for(i=0;i<i1;i++)
    {
        int len=strlen(s1[i]);
        for(j=0;j<len;j++)
            if(s1[i][j]!=' '&&s1[i][j]!='\t'&&s1[i][j]!='\n')
                x1+=s1[i][j];
    }
    for(i=0;i<i2;i++)
    {
        int len=strlen(s2[i]);
        for(j=0;j<len;j++)
            if(s2[i][j]!=' '&&s2[i][j]!='\t'&&s2[i][j]!='\n')
                x2+=s2[i][j];
    }
    //cout<<x1<<" "<<x2<<endl;
    if(x1==x2)
        return 1;
    return 2;
}

int main()
{
    int i,ca=1,T;
    cin>>T;
    getchar();//這個地方一定不能掉,開始我就掉了
    while(T--)
    {
        i1=0,i2=0;
        gets(s1[0]);
        while(gets(s1[i1])&&strcmp(s1[i1],"END")!=0)
        {
            i1++;
        }
        gets(s2[0]);
        while(gets(s2[i2])&&strcmp(s2[i2],"END")!=0)
        {
            i2++;
        }
        int k=xiaohao();
        if(k==0)
            printf("Accepted\n");
        else if(k==2)
            printf("Wrong Answer\n");
        else if(k==1)
            printf("Presentation Error\n");
    }
    return 0;
}
           

繼續閱讀