#include "validate.h" #include #include #include #include #include using namespace std; int main(int argc, char **argv) { init_io(argc, argv); int n; judge_in >> n; stack > hires; vector > edges; for (int i = 0; i < n; i++) { int f, h; judge_in >> f >> h; while (f > 0) { pair past_hire = hires.top(); hires.pop(); edges.emplace_back(past_hire.first, i); int mn = min(past_hire.second, f); f -= mn; if (mn < past_hire.second) { hires.push(make_pair(past_hire.first, past_hire.second - mn)); } } if (h > 0) { hires.push(make_pair(i, h)); } } int judge_cnt; judge_ans >> judge_cnt; int author_cnt; if (!(author_out >> author_cnt)) { wrong_answer("Failed to read claimed #colors\n"); } if (judge_cnt != author_cnt) { wrong_answer("Author solution uses %d people, but judge solution only needs %d people\n", author_cnt, judge_cnt); } vector author_assignment(n); for (int i = 0; i < n; i++) { int x; if (!(author_out >> x)) { wrong_answer("Failed to read color of vertex %d\n", i+1); } if (x < 1 || x > author_cnt) { wrong_answer("Expected person number in range [1,%d], got %d\n", author_cnt, x); } author_assignment[i] = x; } for (auto fp : edges) { if (author_assignment[fp.first] == author_assignment[fp.second]) { wrong_answer("Hire/fire %d and %d have same person, but should be different\n", fp.first+1, fp.second+1); } } string trash; if (author_out >> trash) { wrong_answer("Trailing output\n"); } accept(); }