#include "testlib.h" #include using namespace std; int readAns(InStream& stream, vector& nums) { int size = stream.readInt(1, 1e3); vector ans; while (!stream.seekEof()) ans.push_back(stream.readInt()); if (size != ans.size()) quitf(_wa, "Subsequence does not match size provided"); for (int i = 1; i < ans.size(); i++) { if (ans[i - 1] >= ans[i]) { quitf(_wa, "Subsequence is not strictly increasing"); } } // checking if numbers provided are indeed a subsequence of the original array int j = 0; for (int i = 0; i < nums.size() && j < ans.size(); i++) { if (nums[i] == ans[j]) { j++; } } if (j != size) { quitf(_wa, "The provided subsequence is not present in the original array"); } return size; } int main(int argc, char* argv[]) { setName("Set the name of your checker here"); registerTestlibCmd(argc, argv); int n = inf.readInt(); vector nums(n); for (int i = 0; i < n; i++) nums[i] = inf.readInt(); int ja = readAns(ans, nums); int pa = readAns(ouf, nums); if (ja > pa) quitf(_wa, "Expected (%i) found (%i)", ja, pa); if (ja < pa) quitf(_fail, "Participant gave a better answer. PA - (%i), JA - (%i)", pa, ja); quitf(_ok, "OK"); return 0; }