Advertisement
dvjsharma

Untitled

Jan 24th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. // ~@dvjsharma~ || ~@dvjsharmaa~ //
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  6. #define scan(arr) for(auto &x : arr) cin>>x;
  7. #define print(arr) for(auto &x : arr) cout<<x<<" "; cout<<endl;
  8. #define all(x) x.begin(), x.end()
  9. #define ll long long
  10. #define int long long int
  11. #define endl "\n"
  12. #define NO cout<<"NO"<<"\n"
  13. #define YES cout<<"YES"<<"\n"
  14. #define No cout<<"No"<<"\n"
  15. #define Yes cout<<"Yes"<<"\n"
  16. #define vi vector<int>
  17. #define vvi vector<vector<int>>
  18. #define pb push_back
  19. #define ppb pop_back
  20. #define mod 1e9+7
  21.  
  22. int lenint(int n); //length of any intezer
  23. int ati(int arr[],int n); //array to intezer
  24. int reversal(int n); //reverse intezers
  25. string binary(int n); //int to binary(string)
  26. int digit_sum(int n); //sum of int digits
  27.  
  28. //**************************************************//
  29. int checkif(char a,string s2){
  30. // cout<<a<<s2<<endl;
  31. if(s2.find(a)==true){
  32. return 1;
  33. }
  34. return 0;
  35. }
  36. void solve(){
  37. string s1; cin>>s1;
  38. string s2; cin>>s2;
  39. int arr[s1.size()]={-1};
  40. // int hsh1[26],hsh2[26];
  41. // for(int i=0; i<s1.size(); i++){
  42. // hsh1[s1[i]-'a']++;
  43. // }
  44. // for(int i=0; i<s2.size(); i++){
  45. // hsh2[s2[i]-'a']++;
  46. // }
  47. for(int i=0; i<s1.size(); i++){
  48. arr[i]=checkif(s1[i],s2);
  49. }
  50. int count=0;
  51. for(int i=0; i<s1.size(); i++){
  52. if(arr[i]>0){
  53. count++;
  54. }
  55. }
  56. // print(arr);
  57. // cout<<count<<endl;
  58. if(count==s1.size()){
  59. YES;
  60. }
  61. else{
  62. NO;
  63. }
  64.  
  65. }
  66.  
  67. //**************************************************//
  68.  
  69. signed main(){
  70. fastio();
  71. int tc=1;
  72. cin>>tc;
  73. while(tc--){
  74. solve();
  75. }
  76. return 0;
  77. }
  78.  
  79.  
  80.  
  81. int lenint(ll n){
  82. return floor(log10(n) + 1);
  83. }
  84. int ati(int a[],int n){
  85. int x=0;
  86. for(int i=0; i<n; i++){
  87. x+=a[i];
  88. x*=10;
  89. }
  90. return(x/10);
  91. }
  92. int reversal(int n){
  93. int x=0,j=(int)pow(10,(int)log10(n));
  94. while(n){
  95. x+=(n%10)*j;
  96. n/=10;
  97. j/=10;
  98. }
  99. return x;
  100. }
  101. string binary(int n){
  102. string str="";
  103. int binaryNum[32];
  104. int i = 0;
  105. while (n > 0) {
  106. int x=n%2;
  107. str.push_back(x+'0');
  108. n = n / 2;
  109. }
  110. reverse(all(str));
  111. return str;
  112. }
  113. int digit_sum(int n){
  114. int x=0;
  115. while(n){
  116. x+=n%10;
  117. n/=10;
  118. }
  119. return x;
  120. }
Tags: Doubt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement