Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <cmath>
  3. #include <stdint.h>
  4. using namespace std;
  5.  
  6. vector<pair<bool, uint64_t>> check(1000009, make_pair(false, -10));
  7.  
  8. struct pouint64_t
  9. {
  10. vector<uint64_t> parent;
  11. uint64_t value;
  12. uint64_t number;
  13. vector<uint64_t> children;
  14. };
  15.  
  16. vector<pouint64_t> graph;
  17.  
  18. void creatPouint64_t(uint64_t f)
  19. {
  20. pouint64_t p;
  21. p.value = f;
  22. p.number = graph.size();
  23. check[f] = make_pair(true, p.number);
  24. graph.push_back(p);
  25. }
  26.  
  27. void loc(uint64_t f, uint64_t s)
  28. {
  29. if (check[f].first == false)
  30. creatPouint64_t(f);
  31. if (check[s].first == false)
  32. creatPouint64_t(s);
  33.  
  34. uint64_t lf = check[f].second;
  35. uint64_t ls = check[s].second;
  36.  
  37. graph[lf].children.push_back(graph[ls].value);
  38. graph[ls].parent.push_back(graph[lf].value);
  39. }
  40.  
  41. bool find(uint64_t f, uint64_t s, uint64_t t)
  42. {
  43. uint64_t lf = check[f].second;
  44. uint64_t ls = check[s].second;
  45. uint64_t lt = check[t].second;
  46. pouint64_t pf = graph[lf];
  47. pouint64_t ps = graph[ls];
  48. pouint64_t pt = graph[lt];
  49. bool bf = false;
  50. bool bs = false;
  51. bool bt = false;
  52.  
  53. if (pf.parent.size() == 0)
  54. bf = true;
  55. if (ps.parent.size() == 0)
  56. bs = true;
  57. if (pt.parent.size() == 0)
  58. bt = true;
  59.  
  60. if (bf == true)
  61. {
  62.  
  63. if (bs == true)
  64. {
  65.  
  66. if (bt == true)
  67. return true;
  68.  
  69. else if (bt == false)
  70. {
  71. uint64_t kp = pt.parent.size();
  72. if (kp > 2)
  73. return false;
  74. if (kp == 1)
  75. {
  76. if (pt.parent[0] == pf.value || pt.parent[0] == ps.value)
  77. return true;
  78. else
  79. return false;
  80. }
  81. else if (kp == 2)
  82. {
  83. uint64_t a = pt.parent[0];
  84. uint64_t b = pt.parent[1];
  85. if ((a == pf.value && b == ps.value) || (b == ps.value && a == pf.value))
  86. return true;
  87. else
  88. return false;
  89. }
  90. }
  91. }
  92.  
  93. else if (bs == false)
  94. {
  95.  
  96. if (bt == true)
  97. {
  98. uint64_t ks = ps.parent.size();
  99. if (ks > 1)
  100. return false;
  101. if (ks == 1)
  102. if (ps.parent[0] == pf.value)
  103. return true;
  104. return false;
  105. }
  106.  
  107. else if (bt == false)
  108. {
  109.  
  110. uint64_t ks = ps.parent.size();
  111. if (ks > 1)
  112. return false;
  113. if (ks == 1)
  114. if (ps.parent[0] != pf.value)
  115. return false;
  116.  
  117. uint64_t kt = pt.parent.size();
  118. if (kt > 2)
  119. return false;
  120. if (kt == 1)
  121. {
  122.  
  123. if (pt.parent[0] == pf.value)
  124. return true;
  125. else if (pt.parent[0] == ps.value)
  126. return true;
  127. else
  128. return false;
  129. }
  130. else if (kt == 2)
  131. {
  132.  
  133. uint64_t a = pt.parent[0];
  134. uint64_t b = pt.parent[1];
  135. if (a == pf.value && b == ps.value)
  136. return true;
  137. else if (a == ps.value && b == pf.value)
  138. return true;
  139. else
  140. return false;
  141. }
  142. }
  143. }
  144. }
  145. else
  146. return false;
  147.  
  148. return true;
  149. }
  150.  
  151. int main()
  152. {
  153. uint64_t n, m;
  154. cin >> n >> m;
  155. for (uint64_t i = 0; i < m; i++)
  156. {
  157. uint64_t f, s;
  158. cin >> f >> s;
  159. loc(f, s);
  160. }
  161.  
  162. for (uint64_t i = 0; i < n; i++)
  163. {
  164. uint64_t f, s, t;
  165. cin >> f >> s >> t;
  166. bool b = find(f, s, t);
  167. if (b)
  168. cout << "honest\n";
  169. else
  170. cout << "liar\n";
  171. }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement