Download ICPC/nwerc2022_G/output_validators/validate/validate.cpp from He-Ren/OJBench_testdata: direct link, hf CLI and curl.
- Browser
- Download file 3.4 kB
-
https://huggingface.co/datasets/He-Ren/OJBench_testdata/resolve/main/ICPC/nwerc2022_G/output_validators/validate/validate.cpp
- Command line
-
hf download hf://datasets/He-Ren/OJBench_testdata/ICPC/nwerc2022_G/output_validators/validate/validate.cpp
-
curl -L -o validate.cpp https://huggingface.co/datasets/He-Ren/OJBench_testdata/resolve/main/ICPC/nwerc2022_G/output_validators/validate/validate.cpp
3.4 kB
| int qwerty_getcode(int code) { | |
| return code == 42? 0: 1; | |
| } | |
| namespace std { | |
| void qwerty_exit(int code){ | |
| exit(qwerty_getcode(code)); | |
| } | |
| } using std::qwerty_exit; | |
| using namespace std; | |
| void to_lower(std::string& s) { | |
| for (char& c : s) c |= 0x20; | |
| } | |
| int main(int argc, char **argv) { | |
| init_io(argc,argv); | |
| int n; | |
| judge_in >> n; | |
| int position = 0; | |
| vector<int> state(n); | |
| for (int i = 0; i < n; i++) { | |
| char c; | |
| judge_in >> c; | |
| state[i] = c - '0'; | |
| } | |
| cout << state[position] << endl; | |
| int max_queries = 3*n + 500; | |
| int lim_queries = 5*n + 1000; | |
| int queries_used = 0; | |
| while (true) { | |
| string response; | |
| if (!(author_out >> response)) { | |
| wrong_answer("Wrong answer: failed to read response. Queries used: %d\n", queries_used); | |
| } | |
| if (response == "?") { | |
| queries_used++; | |
| string query; | |
| if (!(author_out >> query)) { | |
| wrong_answer("Wrong answer: failed to read query. Queries used: %d\n", queries_used); | |
| } | |
| to_lower(query); | |
| if (query == "left") { | |
| position = (position + n - 1) % n; | |
| } else if (query == "right") { | |
| position = (position + 1) % n; | |
| } else if (query == "flip") { | |
| state[position] = 1 - state[position]; | |
| } else { | |
| wrong_answer("Wrong answer: invalid query type. Queries used: %d\n", queries_used); | |
| } | |
| cout << state[position] << endl; | |
| } else if (response == "!") { | |
| int guess; | |
| if (!(author_out >> guess)) { | |
| wrong_answer("Wrong answer: failed to read guess. Queries used: %d\n", queries_used); | |
| } | |
| string junk; | |
| if (author_out >> junk) { | |
| wrong_answer("Wrong answer: trailing output after guess.\n"); | |
| } | |
| if (guess == n) { | |
| if (queries_used > max_queries) { | |
| wrong_answer("Wrong answer: correct guess, but used too many queries. Queries used: %d (%d too many)\n", queries_used, queries_used-max_queries); | |
| } | |
| break; | |
| } else { | |
| wrong_answer("Wrong answer: incorrect guess %d (ans: %d). Queries used: %d\n", guess, n, queries_used); | |
| } | |
| } else { | |
| wrong_answer("Wrong answer: invalid response type. Queries used: %d\n", queries_used); | |
| } | |
| if (queries_used > lim_queries) { | |
| wrong_answer("Wrong answer: used too many queries. Queries used: %d (%d too many, terminated)\n", queries_used, queries_used-max_queries); | |
| } | |
| } | |
| string junk; | |
| if (author_out >> junk) { | |
| wrong_answer("Wrong answer: trailing output.\n"); | |
| } | |
| judge_message("Queries used: %d.\n", queries_used); | |
| accept(); | |
| } | |
| int main(int argc, char **argv) { | |
| namespace fs = std::filesystem; | |
| char judge_out[] = "/dev"; | |
| std::vector<char*> new_argv = { | |
| argv[0], argv[1], argv[2], | |
| judge_out, | |
| }; | |
| return qwerty_getcode(qwerty_main((int)new_argv.size(), new_argv.data())); | |
| } | |