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:自己测试对了但是提交是WA( `д′),求助In Reply To:自己测试对了但是提交是WA( `д′),求助 Posted by:zqu971223 at 2016-07-01 21:56:24 > #include <iostream> > #include <fstream> > #include <map> > #include <algorithm> > #include <string> > > using namespace std; > > int find_inver(string str) > { > int length=str.length(); > int i,j,inversion=0; > for(i=0;i<length;++i) > { > for(j=i+1;j<length;++j) > { > if(str[i]>str[j]) inversion++; > } > } > return inversion; > } > > int main() > { > /*fstream infile("test.txt"); > if(!infile) {cerr<<"open file error!\n";return 1;}*/ > int n,m; > //infile>>n>>m; > cin>>n>>m; > > int i,inversion; > string str; > map<int,string> Map; > > for(i=0;i<m;++i) > { > //infile>>str; > cin>>str; > inversion=find_inver(str); > Map[inversion]=str; > } > > map<int,string>::iterator itr; > for(itr=Map.begin();itr!=Map.end();itr++) > cout<<itr->second<<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