Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <cmath>
- #include <stdint.h>
- using namespace std;
- vector<pair<bool, uint64_t>> check(1000009, make_pair(false, -10));
- struct pouint64_t
- {
- vector<uint64_t> parent;
- uint64_t value;
- uint64_t number;
- vector<uint64_t> children;
- };
- vector<pouint64_t> graph;
- void creatPouint64_t(uint64_t f)
- {
- pouint64_t p;
- p.value = f;
- p.number = graph.size();
- check[f] = make_pair(true, p.number);
- graph.push_back(p);
- }
- void loc(uint64_t f, uint64_t s)
- {
- if (check[f].first == false)
- creatPouint64_t(f);
- if (check[s].first == false)
- creatPouint64_t(s);
- uint64_t lf = check[f].second;
- uint64_t ls = check[s].second;
- graph[lf].children.push_back(graph[ls].value);
- graph[ls].parent.push_back(graph[lf].value);
- }
- bool find(uint64_t f, uint64_t s, uint64_t t)
- {
- uint64_t lf = check[f].second;
- uint64_t ls = check[s].second;
- uint64_t lt = check[t].second;
- pouint64_t pf = graph[lf];
- pouint64_t ps = graph[ls];
- pouint64_t 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)
- {
- uint64_t 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)
- {
- uint64_t a = pt.parent[0];
- uint64_t 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)
- {
- uint64_t 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)
- {
- uint64_t ks = ps.parent.size();
- if (ks > 1)
- return false;
- if (ks == 1)
- if (ps.parent[0] != pf.value)
- return false;
- uint64_t 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)
- {
- uint64_t a = pt.parent[0];
- uint64_t 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()
- {
- uint64_t n, m;
- cin >> n >> m;
- for (uint64_t i = 0; i < m; i++)
- {
- uint64_t f, s;
- cin >> f >> s;
- loc(f, s);
- }
- for (uint64_t i = 0; i < n; i++)
- {
- uint64_t 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