| ||||||||||
| 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 | |||||||||
Re:~~呵呵·原来这样改~也能过~In Reply To:~~呵呵·原来这样改~也能过~ Posted by:luketyg at 2009-01-10 19:33:23 > #include "iostream"
> #include "algorithm"
> using namespace std;
> struct data
> {
> int count;
> int a;
> char b[8];
> };
> int map(char x)
> {
> if(x>='0'&&x<='9')
> return x-'0';
> else if(x>='A'&&x<='P')
> return (x-'A')/3+2;
> else if(x>='R'&&x<='Y')
> return (x-'Q')/3+7;
> }
> int Turn(char *str,char *b)
> {
> int Exp=1000000,s=0,k=0;
> size_t i;
> for(i=0;i<strlen(str) ;i++)
> {
> if(str[i]!='-')
> {
> if(k==3)b[k++]='-';
> b[k++]=map(str[i])+'0';
> s+=Exp*map(str[i]);
> Exp/=10;
> }
> }
> b[k]='\0';
> return s;
> }
> bool Cmp(const data &a,const data &b)
> {
> if(a.a<b.a)return 1;
> else return 0;
> }
> int main()
> {
> int t,i;
> cin>>t;
> char (*str)[10]=new char[t][10];
> data *d=new data[t];
> for(i=0;i<t;i++)
> {
> scanf("%s",str[i]); //不用cin输入就过了否则超时~哎!!汗~~
> d[i].a=Turn(str[i],d[i].b);
> d[i].count=1;
> }
> sort(d,d+t,Cmp);
> int now=d[0].a,k=0;
> for(i=1;i<t;i++)
> {
> if(now==d[i].a)d[k].count++;
> else {now=d[i].a;k=i;}
> }
> int flag=0;
> for(i=0;i<t;i++)
> if(d[i].count!=1)
> {
> for(int j=0;j<8;j++)
> cout<<d[i].b[j];
> cout<<" "<<d[i].count<<endl;
> now=d[i].count;
> flag=1;
> }
> if(flag==0)cout<<"No duplicates."<<endl;
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator