#include "validate.h" #include "simulate.h" #include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; typedef long double ld; int main(int argc, char **argv) { init_io(argc, argv); int n, k; judge_in >> n; vector > graph(n, vector()); for(int c1 = 0; c1 < n-1; c1++){ int a, b; judge_in >> a >> b; a--; b--; graph[a].push_back(b); graph[b].push_back(a); } string ans1; judge_ans >> ans1; for (char& c : ans1) c = (char)toupper(c); if(ans1 != "YES" && ans1 != "NO"){ judge_error("Judge answer must be 'yes' or 'no'"); } string ans2; if(!(author_out >> ans2)){ wrong_answer("Could not read first line"); } for (char& c : ans2) c = (char)toupper(c); if(ans2 != "YES" && ans2 != "NO"){ wrong_answer("Did not print 'yes' or 'no'"); } if(ans2 == "NO" && ans1 == "YES"){ wrong_answer("Printed 'no', but solution exists"); } if(ans2 == "YES"){ vector permutation; set seen; for(int c1 = 0; c1 < n; c1++){ int a; if(!(author_out >> a)){ wrong_answer("Could not read %d:th number", c1+1); } if(a < 1 || a > n){ wrong_answer("Out of bounds: the %d:th number was %d", c1+1, a); } permutation.push_back(a-1); if(seen.find(a) != seen.end()){ wrong_answer("Duplicate element %d", a); } seen.insert(a); } vector ant_nodes = simulate_fast(graph, permutation); if(ant_nodes.size() == 1){ wrong_answer("All the ants went to the same vertex"); } if(ans1 == "NO"){ judge_error("Found a solution, but judge claims none exists"); } } string trailing; if(author_out >> trailing){ wrong_answer("Trailing output"); } accept(); }