Advertisement
EWTD

Untitled

Oct 16th, 2019
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
  2. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  3. #include <iostream>
  4. #include <vector>
  5. #include <set>
  6. #include <array>
  7. using namespace std;
  8. const int N = 1000001;
  9. array<set<int>,N> g;
  10. array<bool,N> used;
  11.  
  12. bool check_c(int a, int b,int c){
  13.     auto flag_a = g[c].find(a) != g[c].end();
  14.     auto flag_b = g[c].find(b) != g[c].end();
  15.     auto sz = g[c].size();
  16.     if(flag_b) {
  17.         if(flag_a){
  18.             return sz == 2;
  19.         }
  20.         return sz == 1;
  21.     }
  22.  
  23.     if(flag_a){
  24.         return sz == 1;
  25.     }
  26.  
  27.     return sz == 0;
  28. }
  29. bool check_b(int a, int b){
  30.     auto flag_a = g[b].find(a) != g[b].end();
  31.     auto sz = g[b].size();
  32.     if(flag_a){
  33.         return sz == 1;
  34.     }else{
  35.         return sz == 0;
  36.     }
  37. }
  38. bool check_a(int a){
  39.     return g[a].size() == 0;
  40. }
  41. bool check(int a, int b, int c){
  42.     return check_c(a,b,c) && check_b(a,b) && check_a(a);
  43. }
  44. int main(){
  45.     int n, m;
  46.     cin >> n >> m;
  47.     for(int i = 0 ; i < m; ++i){
  48.         int a, b;
  49.         cin >> a >> b;
  50.         g[b].insert(a);
  51.     }
  52.     for(int i = 0; i < n; ++i){
  53.         int a, b, c;
  54.         cin >> a >> b >> c;
  55.         if (check(a,b,c)){
  56.             cout << "honest\n";
  57.         }else{
  58.             cout << "liar\n";
  59.         }
  60.     }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement