zoukankan      html  css  js  c++  java
  • HDU 1073

    http://acm.hdu.edu.cn/showproblem.php?pid=1073

    模拟oj判题

    随便搞,开始字符串读入的细节地方没处理好,wa了好久

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <map>
    using namespace std ; 
    char s1[100005],s2[100005] ;
    char s3[100005],s4[100005] ;
    int main()
    {
        int t ;
        scanf("%d%*c",&t) ;
        while(t--)
        {
            scanf("%*s%*c") ;
            char ch ;
            int st=0 ;
            while(ch=getchar())
            {
                s1[st++]=ch ;
                if(ch=='
    ' && st>3 && s1[st-4]=='E' && s1[st-3]=='N' && s1[st-2]=='D')
                    break ;
            }
            s1[st-5]='' ;
            scanf("%*s%*c") ;
            st=0 ;
            while(ch=getchar())
            {
                s2[st++]=ch ;
                if(ch=='
    ' && st>3 && s2[st-4]=='E' && s2[st-3]=='N' && s2[st-2]=='D')
                    break ;
            }
            s2[st-5]='' ;
            if(!strcmp(s1,s2))
            {
                puts("Accepted") ;
            }
            else
            {
                st=0 ;
                for(int i=0 ;i<strlen(s1) ;i++)
                    if(s1[i]==' ' || s1[i]=='	' || s1[i]=='
    ')
                        continue ;
                    else
                        s3[st++]=s1[i] ;
                s3[st]='' ;
                st=0 ;
                for(int i=0 ;i<strlen(s2) ;i++)
                    if(s2[i]==' ' || s2[i]=='	' || s2[i]=='
    ')
                        continue ;
                    else
                        s4[st++]=s2[i] ;
                s4[st]='' ;
                if(!strcmp(s3,s4))
                    puts("Presentation Error") ;
                else
                    puts("Wrong Answer") ;
            }
        }
        return 0 ;
    }
    View Code
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <map>
    using namespace std ; 
    char s1[100005],s2[100005] ;
    int main()
    {
        int t ;
        scanf("%d%*c",&t) ;
        while(t--)
        {
            scanf("%*s%*c") ;
            char ch ;
            int st=0 ;
            while(ch=getchar())
            {
                s1[st++]=ch ;
                if(ch=='
    ' && st>3 && s1[st-4]=='E' && s1[st-3]=='N' && s1[st-2]=='D')
                    break ;
            }
            s1[st-5]='' ;
            scanf("%*s%*c") ;
            st=0 ;
            while(ch=getchar())
            {
                s2[st++]=ch ;
                if(ch=='
    ' && st>3 && s2[st-4]=='E' && s2[st-3]=='N' && s2[st-2]=='D')
                    break ;
            }
            s2[st-5]='' ;
            if(!strcmp(s1,s2))
            {
                puts("Accepted") ;
            }
            else
            {
                map <char,int> M1,M2 ;
                for(int i=0 ;i<strlen(s1) ;i++)
                    M1[s1[i]]++ ;
                for(int i=0 ;i<strlen(s2) ;i++)
                    M2[s2[i]]++ ;
                map <char,int> :: iterator it ;
                int f=1 ;
                for(it=M1.begin() ;it!=M1.end() ;it++)
                    if(M2[it->first]!=it->second && it->first!=' ' && it->first!='	' && it->first!='
    ')
                    {
                        f=0 ;
                        break ;
                    }
                if(f)
                    puts("Presentation Error") ;
                else
                    puts("Wrong Answer") ;
            }
        }
        return 0 ;
    }
    View Code
  • 相关阅读:
    #啃underscore源码 一、root对象初始化部分
    LeetCode 7. Reverse Integer (JS)
    LeetCode 1.两数之和(JS)
    【安利】前端基础学习资源
    如何防止XSS攻击?
    浅谈CSRF攻击方式
    node中__dirname、__filename、process.cwd()、process.chdir()表示的路径
    解决Error: ENOENT: no such file or directory, scandir 'xxx ode-sassvendor'
    jquery中attr和prop的区别
    git stash 命令
  • 原文地址:https://www.cnblogs.com/xiaohongmao/p/3525625.html
Copyright © 2011-2022 走看看