#include #include #include #include #include #include #include using namespace std; int find_etalon(vector arr){ if(arr[0]==arr[1]) return 0; if(arr[0]==arr[2]) return 0; if(arr[1]==arr[2]) return 1; } bool ans; bool dfs(map> st, char v){ if(ans) return true; if(st.size()==1) return true; set paths = st[v]; st.erase(v); for(auto i=paths.begin();i!=paths.end();i++){ for(auto el: st){ if(el.second.find(*i)!=el.second.end()){ map> nst(st); if(el.second.size()>1) nst[el.first].erase(*i); //cout << v << el.first << " " << nst.size() <>n){ map> suits, ranks; for(int i=0;i> s; ranks[s[0]].insert(s[1]); suits[s[1]].insert(s[0]); } ans = false; for(auto el:ranks){ ans |=dfs(ranks,el.first); } for(auto el:suits){ ans |=dfs(suits,el.first); } string san = (ans)?"YES":"NO"; cout << san << endl; } return 0; }