#include "validation.h" // For FIXED OUTPUT PROBLEMS: // This program will be called as // output_validator input < ans // // You should verify the grammar of the answer file. // See input_validator.cpp for information on how to use the Validator class. // Furthermore you should check simple properties of the answer. // For DYNAMIC OUTPUT PROBLEMS: // This program will be called as // output_validator input answer < team_output // // Please check the grammar of the team output using the Validator class. // See input_validator.cpp for information on how to use the Validator class. // You should also check the validity of the answer here. // For example, check that a tree printed by the team is a tree indeed. // For INTERACTIVE PROBLEMS: // Write your output validator as usual, but make sure to flush all standard // output. Call `v.set_WA_handler(lambda)` to gracefully handle failures when // parsing team output. You could e.g. send a '-1' to the submission to tell it // to stop running. #include #include int main(int argc, char** argv) { std::ifstream in(argv[1]); OutputValidator v(argc, argv); // Read input. int n,m; in >> n >> m; std::vector> ints(m); for(int i = 0; i < m; i++) { in >> ints[i].first >> ints[i].second; } std::sort(ints.begin(), ints.end()); // compute solution int end = 0; int solution = 0; for(int i = 0; i < m; i++) { if(ints[i].first >= end) { solution++; end = ints[i].second; } } std::cout << n << std::endl; // Interactions. int maxq = 2*n; int queries = 0; while(true) { auto op = v.read_string("op", 1, 1, "?!"); if(op == "?") { queries += 1; if(queries > maxq) { v.WA("Used too many queries"); } // read input v.space(); int x = v.read_integer("x", 0, n); v.space(); long long y = v.read_integer("y", 0, n); v.newline(); v.check(x({x,0})); bool includes = (it != ints.end() and (*it).second <= y); std::cout << (includes ? "absent" : "present") << std::endl; } else if(op == "!") { v.space(); int guess = v.read_integer("s", 0,n); v.check(solution == guess, "Solution incorrect, expected ", solution, " but got ", guess); std::cerr << "Used " << queries << " queries" << std::endl; return 0; } else { v.WA("unknown op ", op); } } }