#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool StringContain(string &a,string &b){
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (int pa = 0, pb = 0; pb < b.length();){
while ((pa<a.length())&&(a[pa]<b[pb]))
{
++pa;
}
if ((pa >= a.length()) || (a[pa]>b[pb])){
return false;
}
++pb;
}
return true;
}
int main()
{
string a, b;
cin >> a;
cin >> b;
bool c;
c=StringContain(a, b);
if (c == true)
cout << "true";
else
cout << "error";
#include<string>
#include<algorithm>
using namespace std;
bool StringContain(string &a,string &b){
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (int pa = 0, pb = 0; pb < b.length();){
while ((pa<a.length())&&(a[pa]<b[pb]))
{
++pa;
}
if ((pa >= a.length()) || (a[pa]>b[pb])){
return false;
}
++pb;
}
return true;
}
int main()
{
string a, b;
cin >> a;
cin >> b;
bool c;
c=StringContain(a, b);
if (c == true)
cout << "true";
else
cout << "error";
}
排序O(mlogm)+O(nlogn)
线性扫描O(m+n)