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

Re:用g++交一直wa,改用c++就a了,好蛋疼

Posted by zhoutonglx at 2015-08-06 09:51:02 on Problem 1002
In Reply To:用g++交一直wa,改用c++就a了,好蛋疼 Posted by:zhoutonglx at 2015-08-06 09:50:23
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<map>
#include<set>
using namespace std;

set<string> se;
map<string,int> mp;
int main()
{
    std::ios::sync_with_stdio(false);
    freopen("a.txt","w",stdout);
    int i,j;
    int n;
    cin>>n;
    char s[356];
    string tmp;
    char ss[356];
    int k;
    int flag;
	int l;
    for(i=0;i<n;i++)
    {
		scanf("%s",s);
		l = strlen(s);
        k=0;
        flag=1;
        for(j=0;j<l;j++)
        {
			if(s[j]=='Q'||s[j]=='Z')
			{
				flag=0;
				break;
			}
            if(s[j]=='A'||s[j]=='B'||s[j]=='C')
            {
                ss[k++]='2';
            } 
            else if(s[j]=='D'||s[j]=='E'||s[j]=='F')
                ss[k++] = '3';
            else if(s[j]=='G'||s[j]=='H'||s[j]=='I')
                ss[k++] = '4';
            else if(s[j]=='J'||s[j]=='K'||s[j]=='L')
                ss[k++] = '5';
            else if(s[j]=='M'||s[j]=='N'||s[j]=='O')
                ss[k++]='6';
            else if(s[j]=='P'||s[j]=='R'||s[j]=='S')
                ss[k++]='7';
            else if(s[j]=='T'||s[j]=='U'||s[j]=='V')
                ss[k++]='8';
            else if(s[j]=='W'||s[j]=='X'||s[j]=='Y')
                ss[k++]='9';
            else if(s[j]>='0'&&s[j]<='9')
                ss[k++]=s[j];
        }
        if(flag==0)
            continue;
        ss[k]=0;
        tmp = ss;
        se.insert(tmp);
        mp[tmp]++;
    } 
    set<string> :: iterator it;
    flag = 1;
    for(it = se.begin();it!=se.end();++it)
    {
        if(mp[(*it)]>1)
        {
            flag=0;
            tmp = (*it);
            for(i=0;i<3;i++)
                cout<<tmp[i];
            cout<<'-';
            for(i=3;i<tmp.size();i++)
                cout<<tmp[i];
            cout<<' '<<mp[tmp]<<endl;
        }
    }
    if(flag)
        cout<<"No duplicates."<<endl;
    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