#include "validation.h" int main(int argc, char** argv) { // Set up the input and answer streams. std::ifstream in(argv[1]); std::ifstream ans(argv[2]); // Only for custom checker. OutputValidator v(argc, argv); std::string is_possible; ans >> is_possible; // This is either "impossible" or a number, but we don't use `ans` in the // "possible" case, so that's fine std::cerr << is_possible << std::endl; if(is_possible == "impossible") { v.test_string("impossible", "is_possible"); v.newline(); } else { int n, m; in >> n; m = n; std::vector> nrs = std::vector>(n + 1, std::set()); for(int i = 0; i < m; i++) { int u, w, h; in >> u >> w >> h; int node = v.read_integer("node", 1, n); if(node == w) std::swap(u, w); if(node == u) { v.check(nrs[u].count(1) == 0, "This node already has a street with this housenumber"); v.check(nrs[w].count(h) == 0, "This node already has a street with this housenumber"); } else { v.check(false, "This street is not connected to this node"); } nrs[u].insert(1); nrs[w].insert(h); v.newline(); } } }