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);
    }
  • 相关阅读:
    POJ 2823 Sliding Window 单调队列
    Java常见面试题汇总(一)
    5.4 heapq--堆队列算法
    使用 rman duplicate from active database 搭建dataguard 手记--系列二
    [LeetCode]Delete Node in a Linked List
    webstorm中使用java的块凝视
    Gradle 1.12用户指南翻译——第三十二章. JDepend 插件
    iOS上如何让按钮(UIbutton)文本左对齐展示
    【matlab】:matlab中不断的出现计算过程怎么办
    apk 签名
  • 原文地址:https://www.cnblogs.com/dshn/p/4750513.html
Copyright © 2011-2022 走看看