Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
- #include <iostream>
- #include <vector>
- #include <set>
- #include <array>
- using namespace std;
- const int N = 1000001;
- array<set<int>,N> g;
- array<bool,N> used;
- bool check_c(int a, int b,int c){
- auto flag_a = g[c].find(a) != g[c].end();
- auto flag_b = g[c].find(b) != g[c].end();
- auto sz = g[c].size();
- if(flag_b) {
- if(flag_a){
- return sz == 2;
- }
- return sz == 1;
- }
- if(flag_a){
- return sz == 1;
- }
- return sz == 0;
- }
- bool check_b(int a, int b){
- auto flag_a = g[b].find(a) != g[b].end();
- auto sz = g[b].size();
- if(flag_a){
- return sz == 1;
- }else{
- return sz == 0;
- }
- }
- bool check_a(int a){
- return g[a].size() == 0;
- }
- bool check(int a, int b, int c){
- return check_c(a,b,c) && check_b(a,b) && check_a(a);
- }
- int main(){
- int n, m;
- cin >> n >> m;
- for(int i = 0 ; i < m; ++i){
- int a, b;
- cin >> a >> b;
- g[b].insert(a);
- }
- for(int i = 0; i < n; ++i){
- int a, b, c;
- cin >> a >> b >> c;
- if (check(a,b,c)){
- cout << "honest\n";
- }else{
- cout << "liar\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement