zoukankan      html  css  js  c++  java
  • Judging Troubles(字典序)

    Judging Troubles
    Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:65536KB
    Total submit users: 84, Accepted users: 61
    Problem 13352 : No special judgement
    Problem description

    2015年08月02日 - 凌晨一点 - 虚灵
    The NWERC organisers have decided that they want to improve the automatic grading of the submissions for the contest, so they now use two systems: DOMjudge and Kattis. Each submission is judged by both systems and the grading results are compared to make sure that the systems agree. However, something went wrong in setting up the connection between the systems, and now the jury only knows all results of both systems, but not which result belongs to which submission! You are therefore asked to help them figure out how many results could have been consistent.

    Input

    The input consists of:
    ? one line with one integer n (1 ≤ n ≤ 10^5), the number of submissions;
    ? n lines, each with a result of the judging by DOMjudge, in arbitrary order;
    ? n lines, each with a result of the judging by Kattis, in arbitrary order.
    Each result is a string of length between 5 and 15 characters (inclusive) consisting of lowercase letters.

    Output

    Output one line with the maximum number of judging results that could have been the same for both systems.

    Sample Input
    5
    correct
    wronganswer
    correct
    correct
    timelimit
    wronganswer
    correct
    timelimit
    correct
    timelimit
    Sample Output
    4
    Problem Source
    NWERC 2014
    Submit   Discuss   Judge Status  Problems  Ranklist 

    题意就是看看给出的两个评测系统的n的结果,让你求有多少个是相同的提交

    思路:字典序

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    using namespace std;
    struct node
    {
        char ch[20];
    };
    node ch1[100005],ch2[100005];
    int comp(node a,node b)
    {
        return strcmp(a.ch,b.ch)<0;
    }
    int main()
    {
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        scanf("%s",ch1[i].ch);
        sort(ch1,ch1+n,comp);
        //for(int i=0;i<n;i++)
       // cout<<ch1[i].ch<<endl;
        for(int j=0;j<n;j++)
        scanf("%s",ch2[j].ch);
        sort(ch2,ch2+n,comp);
        int i=0;
        int j=0;
        int cout=0;
        while(1)
        {
    
            int k=strcmp(ch1[i].ch,ch2[j].ch);
            //printf("!!!
    ");
            if(k==0)
            {
               cout++;
               i++;
               j++;
               if(i==n&&j==n)
               break;
            }
            else if(k<0)
            {
                i++;
                if(i==n)
                break;
            }
            else if(k>0)
            {
                j++;
                if(j==n)
                break;
            }
        }
        printf("%d
    ",cout);
    }
  • 相关阅读:
    ::before和::after伪元素的用法
    JS中map、some、every、filter方法
    C++多线程,互斥,同步
    RAII
    Proxy 代理
    Decorator 装饰
    TCP和UDP的9个区别是什么
    谈谈自己对面向对象的理解
    C++11多线程
    std::move
  • 原文地址:https://www.cnblogs.com/dshn/p/4750513.html
Copyright © 2011-2022 走看看