Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector< pair<bool,int> > check(1000009,make_pair(false,-10));
- struct point {
- vector<int> parent;
- int value;
- int number;
- vector<int> children;
- };
- vector<point> graph;
- void creatPoint(int f) {
- point p;
- p.value=f;
- p.number=graph.size();
- check[f]=make_pair(true,p.number);
- graph.push_back(p);
- }
- void loc(int f,int s) {
- if(check[f].first==false) creatPoint(f);
- if(check[s].first==false) creatPoint(s);
- int lf=check[f].second;
- int ls=check[s].second;
- graph[lf].children.push_back(graph[ls].value);
- graph[ls].parent.push_back(graph[lf].value);
- }
- bool find(int f,int s,int t) {
- int lf=check[f].second;
- int ls=check[s].second;
- int lt=check[t].second;
- point pf = graph[lf]; point ps = graph[ls]; point pt = graph[lt];
- bool bf=false; bool bs=false; bool bt=false;
- if(pf.parent.size()==0) bf=true;
- if(ps.parent.size()==0) bs=true;
- if(pt.parent.size()==0) bt=true;
- if(bf==true) {
- if(bs==true) {
- if(bt==true) return true;
- else if(bt==false) {
- int kp = pt.parent.size();
- if(kp>2) return false;
- if(kp==1) {
- if(pt.parent[0]==pf.value||pt.parent[0]==ps.value) return true;
- else return false;
- } else if(kp==2) {
- int a=pt.parent[0]; int b=pt.parent[1];
- if((a==pf.value&&b==ps.value)||(b==ps.value&&a==pf.value)) return true;
- else return false;
- }
- }
- }
- else if(bs==false) {
- if(bt==true) {
- int ks = ps.parent.size();
- if(ks>1) return false;
- if(ks==1) if(ps.parent[0]==pf.value) return true;
- return false;
- }
- else if(bt==false) {
- int ks = ps.parent.size();
- if(ks>1) return false;
- if(ks==1) if(ps.parent[0]!=pf.value) return false;
- int kt = pt.parent.size();
- if(kt>2) return false;
- if(kt==1) {
- if(pt.parent[0]==pf.value) return true;
- else if(pt.parent[0]==ps.value) return true;
- else return false;
- } else if(kt==2) {
- int a = pt.parent[0]; int b = pt.parent[1];
- if(a==pf.value&&b==ps.value) return true;
- else if(a==ps.value&&b==pf.value) return true;
- else return false;
- }
- }
- }
- }else return false;
- return true;
- }
- int main() {
- int n,m;
- cin>>n>>m;
- for(int i=0;i<m;i++) {
- int f,s;
- cin>>f>>s;
- loc(f,s);
- }
- for(int i=0;i<n;i++) {
- int f,s,t;
- cin>>f>>s>>t;
- bool b = find(f,s,t);
- if(b) cout<<"honest\n";
- else cout<<"liar\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement