| Judging Troubles |
| Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:65536KB |
| Total submit users: 85, Accepted users: 63 |
| Problem 13352 : No special judgement |
| Problem description |
|
|
| Input |
|
The input consists of: |
| 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#include<stdio.h>
struct node{
node* nxt[26];
int k;
node(){
for(int i=0; i<26; i++)
nxt[i]=NULL;
k=0;
}
};
node* root;
void inset(char s[])
{
node* p=root;
int i=0;
while(s[i]!='\0'){
if(p->nxt[s[i]-'a']==NULL)
p->nxt[s[i]-'a']=new node();
p=p->nxt[s[i]-'a'];
i++;
}
(p->k)++;
}
int query(char s[])
{
node* p=root;
int i=0;
while(s[i]!='\0'&&p->nxt[s[i]-'a']!=NULL){
p=p->nxt[s[i]-'a'];
i++;
}
if(p->k&&s[i]=='\0')
{
(p->k)--; return 1;
}
return 0;
}
int main()
{
int n;
char s[20];
while(scanf("%d",&n)>0)
{
root=new node();
for(int i=0; i<n; i++)
{
scanf("%s",s);
inset(s);
}
int ans=0;
while(n--)
{
scanf("%s",s);
ans+=query(s);
}
printf("%d\n",ans);
}
}
|
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/u010372095/article/details/47210499