6 solutions
-
8
#include<iostream> using namespace std; string z,c; int len; int find(int L, int R) { for(int i=0;i<len;i++){ for(int j=L;j<=R;j++){ if(c[i]==z[j]) return j; } } } void f(int l,int r){ int m=find(l,r); cout<<z[m]; if(m>l)f(l,m-1); if(r>m)f(m+1,r); } int main(){ cin>>z; cin>>c; len=c.size(); f(0,z.size()-1); }
-
0
#include<iostream> using namespace std; string z,c; int len; int find(int L, int R) { for(int i=0;i<len;i++){ for(int j=L;j<=R;j++){ if(c[i]==z[j]) return j; } } } void f(int l,int r){ int m=find(l,r); cout<<z[m]; if(m>l)f(l,m-1); if(r>m)f(m+1,r); } int main(){ cin>>z; cin>>c; len=c.size(); f(0,z.size()-1); }
-
-1
#include #include <string> using namespace std; string zhong; string ceng; //int find(int l,int r) //{ // for (int i=0;i<ceng.length();i++) // { // for (int j=l;j<=r;j++){ // if (ceng[i]==zhong[j]){ // return j; // } // } // } //} void f(int l,int r) { //cout << l << "\t" << r <<endl; int mid=0; for (int i=0;i<ceng.length();i++) { bool flag=true; for (mid=l;mid<=r;mid++){ if (ceng[i]==zhong[mid]){ flag=false; break; } } if (flag==false) { break; } } cout << zhong[mid]; if(l<mid){ f(l,mid-1); } if(mid<r){ f(mid+1,r); } } int main() { cin >> zhong; cin >> ceng; f(0,zhong.length()-1); }
-
-1
#include<iostream> using namespace std; string z,c; int len; int find(int L, int R) { for(int i=0;i<len;i++){ for(int j=L;j<=R;j++){ if(c[i]==z[j]) return j; } } } void f(int l,int r){ int m=find(l,r); cout<<z[m]; if(m>l)f(l,m-1); if(r>m)f(m+1,r); } int main(){ cin>>z; cin>>c; len=c.size(); f(0,z.size()-1); }
-
-2
#include<iostream> using namespace std; string z,c; int len; int find(int L, int R) { for(int i=0;i<len;i++){ for(int j=L;j<=R;j++){ if(c[i]==z[j]) return j; } } } void f(int l,int r){ int m=find(l,r); cout<<z[m]; if(m>l)f(l,m-1); if(r>m)f(m+1,r); } int main(){ cin>>z; cin>>c; len=c.size(); f(0,z.size()-1); }
- 1
Information
- ID
- 849
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 84
- Accepted
- 30
- Uploaded By