这一题又是测试都正确,但是一直wa,无语啊,到底哪里错了,上一场也是这个样子,我觉得我需要请人指点一下才行了,自己已经无法突破了。
1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<string> 5 #include<algorithm> 6 #include<vector> 7 #define nnn 1000001 8 using namespace std; 9 vector<string> s1; 10 vector<string> s2; 11 void read(string s1,string& s2){ 12 for(int i=0;i<s1.length();i++){ 13 int num=0; 14 while(isdigit(s1[i])){ 15 num=num*10+s1[i]-‘0‘; 16 i++; 17 } 18 while(num--){ 19 s2.push_back(s1[i]); 20 } 21 } 22 } 23 24 int main(){ 25 string temp,dsttemp1,dsttemp2; 26 int T,len; 27 cin>>T; 28 for(int Case=1;Case<=T;Case++){ 29 cin>>len; 30 s1.clear(); 31 s2.clear(); 32 getchar(); 33 getline(cin,temp); 34 read(temp,dsttemp1); 35 getline(cin,temp); 36 read(temp,dsttemp2); 37 int num=dsttemp2.length()/len; 38 int tempnum=0; 39 while(tempnum<num){ 40 string temp1,temp2; 41 for(int i=tempnum;i<dsttemp1.length();i+=num){ 42 temp1+=dsttemp1[i]; 43 temp2+=dsttemp2[i]; 44 } 45 s1.push_back(temp1); 46 s2.push_back(temp2); 47 tempnum++; 48 } 49 sort(s1.begin(),s1.end()); 50 sort(s2.begin(),s2.end()); 51 for(num=0;num<s1.size();num++){ 52 if(s1[num]!=s2[num]){ 53 cout<<"Case "<<Case<<": No"<<endl; 54 break; 55 } 56 } 57 if(num==s1.size()) 58 cout<<"Case "<<Case<<": Yes"<<endl; 59 } 60 }
微软编程之美初赛第二场第二题字符串压缩,布布扣,bubuko.com
原文:http://www.cnblogs.com/royjwy/p/3681329.html