#include #include #include "validate.h" using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef pair pll; typedef vector vi; typedef vector vl; typedef long double ld; string lower(string s){ for(int c1 = 0; c1 < s.length(); c1++){ s[c1] = tolower(s[c1]); } return s; } int toint(string s){ int res = 0; for(int c1 = 0; c1 < s.length(); c1++){ res *= 10; if('0' <= s[c1] && s[c1] <= '9'){ res += s[c1]-'0'; } else{ return -1; } } return res; } void check_case(){ int n,m,k; judge_in >> n >> m >> k; vector A(n); for(int c1 = 0; c1 < n; c1++){ judge_in >> A[c1]; } string first_line; if(!(author_out >> first_line)){ wrong_answer("Could not read first number of contestants output.\n"); } string judge_first_line; judge_ans >> judge_first_line; if(lower(first_line) == "impossible"){ if(lower(judge_first_line) == "impossible")return; wrong_answer("Contestant printed 'impossible', but an answer existed.\n"); } int first_int = toint(first_line); if(first_int == -1){ wrong_answer("First number was not a positive integer.\n"); } vi ans, ans2; ans.push_back(first_int); for(int c1 = 1; c1 < n; c1++){ int temp; if(!(author_out >> temp)){ wrong_answer("Could not read %d:th number of contestants output.\n", c1+1); } ans.push_back(temp); } trav(a, ans){ ans2.push_back(a); } sort(all(ans2)); for(int c1 = 0; c1 < n; c1++){ if(ans2[c1] != c1+1){ wrong_answer("Contestant printed N integers, but it wasn't a permutation.\n"); } } if(k%m != 0){ wrong_answer("Contestant claims solution exists, but K wasn't divisible by M.\n"); } int goal = k/m; int scores = 1; for(int c1 = 1; c1 < n; c1++){ if(A[ans[c1]-1] * c1 >= scores * m)scores++; } if(scores != goal){ wrong_answer("Contestant printed a valid permutation, but it gave the wrong average score.\n"); } if(lower(judge_first_line) == "impossible"){ judge_error("Judge printed 'impossible', but contestant found a solution.\n"); } } int main(int argc, char **argv) { init_io(argc, argv); check_case(); /* Check for trailing output. */ string trash; if (author_out >> trash) { wrong_answer("Trailing output\n"); } accept(); return 0; }