标签:blog io ar os sp for div log bs
这是我做的第一道水题来着..
#include <iostream> #include <cstdio> #include <map> #include <string> #include <vector> #include <algorithm> using namespace std; map<string ,int> m; string str; vector <string> q; char readchar(){ char ch; while(1){ ch=getchar(); if(ch>=‘A‘&&ch<‘Q‘){ ch=(ch-‘A‘)/3+2+‘0‘; break; } else if(ch>‘Q‘&&ch<‘Z‘){ ch=(ch-‘A‘-1)/3+2+‘0‘; break; } else if(ch<=‘9‘&&ch>=‘0‘){ break; } } return ch; } int main(){ int k; cin>>k; while(k--){ str=""; for(int i=0;i<7;i++){ str+=readchar(); } if(m[str]){ m[str]++; } else { m[str]=1; q.push_back(str); } } sort(q.begin(),q.end()-1); bool fl=true; for(vector<string>::iterator i=q.begin();i<q.end();i++){ if(m[*i]>1){ cout<<i->substr(0,3)<<"-"<<i->substr(3,4)<<" "<<m[*i]<<endl; fl=false; } } if(fl){ cout<<"No duplicates."<<endl; } return 0; }
标签:blog io ar os sp for div log bs
原文地址:http://www.cnblogs.com/xuesu/p/4106221.html