Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // sequences
  4. //
  5. // Created by Ayazhan on 15/09/2019.
  6. // Copyright © 2019 Ayazhan. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <cstdlib>
  11. #include <cstring>
  12.  
  13.  
  14. const int MAX_LENGTH = 2;
  15. const int MAX_REQUEST = 500000;
  16. const int MAX_N = 8836;
  17. const int MAX_M = 100000;
  18.  
  19. int main() {
  20. int n_forbiden;
  21. int n_requests;
  22.  
  23. scanf("%d%d", &n_forbiden, &n_requests);
  24.  
  25. char** arr_forbiden_strs = (char**)calloc(n_forbiden, sizeof(*arr_forbiden_strs) );
  26. for(int i = 0; i < n_forbiden; i++)
  27. {
  28. arr_forbiden_strs[i] = (char*)calloc(MAX_LENGTH, sizeof(char));
  29. std::cin >> arr_forbiden_strs[i];
  30. }
  31.  
  32. char** arr_requests_strs = (char**)calloc(n_requests, sizeof(*arr_requests_strs) );
  33. for(int i = 0; i < n_requests; i++)
  34. {
  35. arr_requests_strs[i] = (char*)calloc(MAX_REQUEST, sizeof(char));
  36. std::cin >> arr_requests_strs[i];
  37. }
  38.  
  39.  
  40. for(int i = 0; i < n_requests; i++)
  41. {
  42. bool indicator = false;
  43.  
  44. for(int j = 0; i < n_forbiden; j++)
  45. {
  46. printf("%s %c", arr_requests_strs[i], arr_forbiden_strs[j][0]);
  47. char* ptr = strchr(arr_requests_strs[i], arr_forbiden_strs[j][0]);
  48. printf("%s\n", ptr);
  49.  
  50. if(ptr)
  51. {
  52. if(strchr(ptr, arr_forbiden_strs[j][1])) indicator = true;
  53. }
  54.  
  55. }
  56.  
  57. if(indicator) printf("YES\n");
  58. else printf("NO\n");
  59. }
  60.  
  61.  
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement