| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求大牛的指导!#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
const int size = 10010;
typedef struct
{
char str[10];
int count;
}Node;
Node node[size];
char hash[30]="22233344455566677778889999";
int n,times;
int cmp(const void *_a,const void *_b)
{
Node *a=(Node*)_a;
Node *b=(Node*)_b;
return b->count-a->count;
}
void result(char s[])
{
int lens,len,i,j,k,flag,c=0,l;
lens=strlen(s);
j=0;
for(i=1;i<=n;i++)
{
len=strlen(node[i].str);
flag=0;
for(;j<len;j++)
{
for(k=0;k<j;k++)
if(hash[node[i].str[k]-'a']!=s[k])
{
flag=1;
break;
}
if(flag)
break;
else
{
if(hash[node[i].str[j]-'a']==s[j])
{
c++;
for(k=0;k<=j;k++)
cout<<node[i].str[k];
cout<<endl;
}
else
{
break;
}
}
}
}
for(l=c+1;l<lens;l++)
cout<<"MANUALLY"<<endl;
}
int main()
{
int cases,m,i;
char s1[10];
cin>>cases;
times=1;
while(cases--)
{
cin>>n;
for(i=1;i<=n;i++)
cin>>node[i].str>>node[i].count;
qsort(node+1,n,sizeof(node[0]),cmp);
cout<<"Scenario #%d:"<<times<<endl;
cin>>m;
while(m--)
{
cin>>s1;
if(strcmp(s1,"1"))
result(s1);
if(m>1)
cout<<endl;
}
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator