您的位置:首页 > 其它

Judging Troubles(字典序)

2015-08-22 16:31 423 查看
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


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("!!!\n");
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\n",cout);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: