fork(2) download
  1. #include <iostream>
  2. #include <set>
  3. #include <iterator>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. set<int>q1;
  9. set<int>q2;
  10. set<int>q3;
  11. int t;
  12. string x, y, z;
  13. set<int>::iterator itr;
  14.  
  15. bool spr()
  16. {
  17. for(itr=q1.begin(); itr!=q1.end(); itr++)
  18. {
  19. if(binary_search(q2.begin(), q2.end(), *itr))
  20. {
  21. return true;
  22. }
  23. if(binary_search(q3.begin(), q3.end(), *itr))
  24. {
  25. return true;
  26. }
  27. }
  28. for(itr=q2.begin();itr!=q2.end(); ++itr)
  29. {
  30. if(binary_search(q3.begin(), q3.end(), *itr))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36.  
  37. int main()
  38. {
  39. cin>>t;
  40. while(t--)
  41. {
  42. q1.clear();
  43. q2.clear();
  44. q3.clear();
  45. cin>>x>>y>>z;
  46. int k;
  47. for(int i=0; i<x.length(); ++i)
  48. {
  49. k=(int)x[i];
  50. q1.insert(k);
  51. }
  52. for(int i=0; i<y.length(); ++i)
  53. {
  54. k=(int)y[i];
  55. q2.insert(k);
  56. }
  57. for(int i=0; i<z.length(); ++i)
  58. {
  59. k=(int)z[i];
  60. q3.insert(k);
  61. }
  62.  
  63. if(spr())
  64. cout<<"TAK"<<endl;
  65. else
  66. cout<<"NIE"<<endl;
  67.  
  68.  
  69. }
  70. return 0;
  71. }
  72.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Standard output is empty