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

求数据,老是WA,求高手帮小弟看一下!!

Posted by 1030690116 at 2011-05-08 15:49:51 on Problem 1002
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    long long n;
    string m;
    vector<string> v;
    cin>>n;
       for(long long i=0;i<n;i++)
       {
           cin>>m;
           v.push_back(m);
       }
       for(long long i=0;i<n;i++)
       {
           for(long long j=0;j<v[i].length();j++)
           {
               while(v[i][j]=='-') v[i].erase(j,1);
               if(v[i][j]>='A'&&v[i][j]<='C') v[i][j]='2';
               if(v[i][j]>='D'&&v[i][j]<='F') v[i][j]='3';
               if(v[i][j]>='G'&&v[i][j]<='I') v[i][j]='4';
               if(v[i][j]>='J'&&v[i][j]<='L') v[i][j]='5';
               if(v[i][j]>='M'&&v[i][j]<='O') v[i][j]='6';
               if(v[i][j]>='P'&&v[i][j]<='S'&&v[i][j]!='Q') v[i][j]='7';
               if(v[i][j]>='T'&&v[i][j]<='V') v[i][j]='8';
               if(v[i][j]>='W'&&v[i][j]<='Y') v[i][j]='9';
           }
       }
       sort(v.begin(),v.end());
       for(long long i=0;i<n;i++)
          v[i].insert(v[i].begin()+3,'-');
       long long c[100001],ans=1;
       long long i;
       for(i=1;i<n;i++)
       {
           if(v[i]==v[i-1]) ans++;
           else
           {
               c[i-1]=ans;
               ans=1;
           }
       }
       c[i-1]=ans;
       bool check=0;
       for(long long i=0;i<n;i++)
       {
           if(c[i]>1) {cout<<v[i]<<' '<<c[i]<<endl;check=1;} 
           else continue;
       }
       if(!check) cout<<"No duplicates."<<endl;
       v.clear();
    system("pause");
    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