#include "validate.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, m; judge_in >> n >> m; set edges; for(int c1 = 0; c1 < m; c1++){ int a, b; judge_in >> a >> b; a--; b--; edges.insert({a, b}); edges.insert({b, a}); } vi ans; set unique; 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 <= 0 || a > n){ wrong_answer("%d:th number out of range (%d)", c1+1, a); } ans.push_back(a-1); unique.insert(a-1); } if(ans[0] != 0){ wrong_answer("The first number wasn't 1"); } if(unique.size() != n){ wrong_answer("Visited the same node multiple times"); } int changes = 0; for(int c1 = 1; c1 < n-1; c1++){ int color1 = (edges.find({ans[c1-1], ans[c1]}) == edges.end()); int color2 = (edges.find({ans[c1], ans[c1+1]}) == edges.end()); if(color1 != color2)changes++; } if(changes > 1){ wrong_answer("Changed color too many times (%d)", changes); } string trailing; if(author_out >> trailing){ wrong_answer("Trailing output"); } accept(); }