fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int t;cin>> t;
  5. while (t--){
  6. int n,m;cin>>n>>m;
  7. char p[n];
  8. char q[m];
  9. char a[3];
  10. char b[n-3];
  11. for (int i=0;i<n;i++){
  12. cin>>p[i];
  13. }
  14. for (int j=0;j<m;j++){
  15. cin >>q[j];
  16. }
  17. int j=0;
  18. int cnts=0;
  19. int cntx=0;
  20. int cnti=0;int y=0;
  21. if (n<m){
  22. cout <<"No" <<'\n';
  23. continue;
  24. }
  25. else{
  26. for (int i=0;i<n;i++){
  27. if (p[i]=='s' && cnts==0){
  28. cnts++;
  29. a[y]=='s';
  30. y++;
  31. }
  32. else if (p[i]=='x' && cntx==0){
  33. cntx++;
  34. a[y]=='x';
  35. y++;
  36. }
  37. else if (p[i]=='i' && cnti==0){
  38. cnti++;
  39. a[y]=='i';
  40. y++;
  41. }
  42. else if ((p[i]=='s' and cnts==1) &&(p[i]=='i' and cnti==1)&&(p[i]=='x' and cntx==1)){
  43. b[j]=p[i];
  44. j++;
  45. }
  46. else {
  47. b[j]=p[i];
  48. j++;
  49. }
  50. }
  51. if (cnts==0 or cntx==0 or cnti==0){
  52. cout << "No" << '\n';
  53. continue;
  54. }
  55. //bالبسط من غير six
  56. //asix
  57. //qالمقام
  58. else {
  59. if (n==3 && m!=0)
  60. {
  61. cout << "No"<<'\n';
  62. continue;
  63. }
  64. }
  65. int lenb=sizeof(b);
  66. int lenq=sizeof(q);
  67. if (lenb!=lenq){
  68. cout << "No" << '\n';
  69. }
  70. else
  71. {sort(b,b+n-3);
  72. sort(q,q+m);
  73. int ans=0;
  74. for (int i=0;i<n-3;i++){
  75. if (b[i]!=q[i]){
  76. cout <<"No" <<'\n';
  77. ans++;
  78. break;
  79. }
  80. }
  81. if (ans==0){
  82. cout <<"Yes" <<'\n';
  83. }
  84. }
  85. }
  86. }
  87. }
Success #stdin #stdout 0s 544KB
stdin
Standard input is empty
stdout
Standard output is empty