Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

1A 贴代码纪念一下 写的渣 凑合着看

Posted by Yt_zp at 2015-08-21 16:08:26 on Problem 1002
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define maxn 100000+10
using namespace std;
char a[150];
struct m{
    char b[20];
}my[maxn];
bool cmp(m a,m b){
    return (strcmp(a.b,b.b)<0);
}
int main(){
    a['1']='1';a['2']='2';a['3']='3';a['4']='4';
    a['5']='5';a['6']='6';a['7']='7';a['8']='8';
    a['9']='9';a['0']='0';
    a['A']=a['B']=a['C']='2';
    a['D']=a['E']=a['F']='3';
    a['G']=a['H']=a['I']='4';
    a['L']=a['K']=a['J']='5';
    a['M']=a['N']=a['O']='6';
    a['P']=a['R']=a['S']='7';
    a['T']=a['U']=a['V']='8';
    a['Y']=a['X']=a['W']='9';
    int n;
    scanf("%d",&n);
    int k=0;
    char s[30];
    while(n--){
        scanf("%s",s);
        int count=0;
        for(int i=0;i<strlen(s);++i){
            if(count==3)my[k].b[count++]='-';
            if(s[i]!='-')my[k].b[count++]=a[s[i]];
        }
        my[k].b[count]='\0';
        k++;
    }
    //printf("--------------------------------\n");
    sort(my,my+k,cmp);
    int ans;
    bool flag=true;
    //for(int i=0;i<k;++i)printf("%s\n",my[i].b);
    for(int i=0;i<k;++i){
        ans=1;
        while(!strcmp(my[i].b,my[i+1].b)){
                ++i;
                ans++;
            }
        if(ans>1)printf("%s %d\n",my[i-1].b,ans);
        if(ans>1)flag=false;
    }
    if(flag)printf("No duplicates.\n");
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator