zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 173 B

    B - Judge Status Summary


    Time Limit: 2 sec / Memory Limit: 1024 MB

    Score : 200200 points

    Problem Statement

    Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.

    The problem has NN test cases.

    For each test case ii (1iN1≤i≤N), you are given a string SiSi representing the verdict for that test case. Find the numbers of test cases for which the verdict is ACWATLE, and RE, respectively.

    See the Output section for the output format.

    Constraints

    • 1N1051≤N≤105
    • SiSi is ACWATLE, or RE.

    Input

    Input is given from Standard Input in the following format:

    NN
    S1S1
    
    SNSN
    

    Output

    Let C0C1C2C2, and C3 be the numbers of test cases for which the verdict is ACWATLE, and RE, respectively. Print the following:

    AC x C0
    WA x C1
    TLE x C2
    RE x C3
    

    Sample Input 1 Copy

    Copy
    6
    AC
    TLE
    AC
    AC
    WA
    TLE
    

    Sample Output 1 Copy

    Copy
    AC x 3
    WA x 1
    TLE x 2
    RE x 0
    

    We have 331122, and 00 test case(s) for which the verdict is ACWATLE, and RE, respectively.

    解题思路:小学计数问题,不过多解释,看题目就能懂

    解法1,利用字符串模拟:

    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main(void)
    {
        int n;
        int a[4];
        char ch[10];
        char str[4][10]={{"AC"},{"WA"},{"TLE"},{"RE"}};
        while(~scanf("%d",&n))
        {
            memset(a,0,sizeof(a));
            getchar();
            for(int i=0;i<n;++i)
            {
                scanf("%s",ch);
                for(int j=0;j<4;++j)
                {
                    if(strcmp(ch,str[j])==0)
                    a[j]++;
                }
            }
            for(int i=0;i<4;++i)
                printf("%s x %d
    ",str[i],a[i]);
        }
        
        return 0;
    }

    解法2,利用STL的map:

    #include<iostream>
    #include<cstdio>
    #include<map>
    using namespace std;
    int main(void)
    {
        ios::sync_with_stdio(false);
        map<string,int> mp;
        int n;
        char ch[10];
        while(cin>>n)
        {
            for(int i=0;i<n;++i)
            cin>>ch,mp[ch]++;
            printf("AC x %d
    ",mp["AC"]);
            printf("WA x %d
    ",mp["WA"]);
            printf("TLE x %d
    ",mp["TLE"]);    
            printf("RE x %d
    ",mp["RE"]);
        }
        return 0;
    }
  • 相关阅读:
    Windows 10下CUDA及cuDNN的安装 —— Pytorch
    Centos7 python3环境搭建 兼容python2.7
    VMware中Linux虚拟机与Windows主机共享文件夹
    基于阿里云服务器的网站搭建 新手教程
    CVE-2017-11882 漏洞分析总结 新手漏洞分析详细教程
    Linux基本命令 和 Regex 正则表达式
    Shell 编程 基础用法
    Perl 编程 基础用法
    Python3 网络通信 网络聊天室 文件传输
    Ant Design of Angular
  • 原文地址:https://www.cnblogs.com/Mangata/p/13289856.html
Copyright © 2011-2022 走看看