不知道简便方法行不行,老是超时

可以简化版吗,太长了输出需要一样
http://t.csdn.cn/rYYlr
我的代码如下
#include
#include
#include
#include using std::cin;using std::cout;using std::vector;using std::string;using std::find;class Solution{public: static vector tags(vector inputs){ vector tag; for(string x:inputs){ if(x[0]=='#'&&x.size()>1&&x.find('#',1)==x.npos){ tag.push_back(x); } } return tag; } static int tag_num(vectortag){ int num=0; int flag=0; for(string x:tag){ if(count(tag.begin()+flag, tag.end(), x)<=1){ num++; } flag++; } return num; } static int single(string x,vectortag){ int num=0; for(string y:tag){ if(x.compare(y)==0){ num++; } } return num; }};int main(int argc, char const *argv[]){ string str; vector orn; while(cin>>str){ orn.push_back(str); } vector tags(Solution::tags(orn)); cout<<Solution::tag_num(tags)<<std::endl; vector tags_new(tags); //sort( tags_new.begin(), tags_new.end() ); tags_new.erase( unique( tags_new.begin(), tags_new.end() ), tags_new.end() ); for(auto x:tags_new){ cout<<x<<" "<<Solution::single(x,tags)<<std::endl; } return 0;}

做一下排版,编辑器有代码块。
这样的基本没人看。