feat: new dp problem formated
This commit is contained in:
52
longest-increasing-subsequence/src/checker.cpp
Normal file
52
longest-increasing-subsequence/src/checker.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "testlib.h"
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool isPaAnswerOk(vector<int> &nums, vector<int> &ans) {
|
||||
for (int i = 1; i < ans.size(); i++) {
|
||||
if (ans[i - 1] >= ans[i]) return false;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0, j = 0; i < nums.size() && j < ans.size(); i++) {
|
||||
if (nums[i] == ans[j]) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return j == (int)ans.size();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
setName("Set the name of your checker here");
|
||||
registerTestlibCmd(argc, argv);
|
||||
|
||||
int n = inf.readInt();
|
||||
vector<int> nums(n);
|
||||
for (int i = 0; i < n; i++) nums[i] = inf.readInt();
|
||||
|
||||
int ja = ans.readInt();
|
||||
int pa = ouf.readInt(1, 1e3);
|
||||
|
||||
vector<int> paAns;
|
||||
while (!ouf.seekEof())
|
||||
paAns.push_back(ouf.readInt());
|
||||
|
||||
if (pa != paAns.size())
|
||||
quitf(_wa, "Subsequence does not match size provided");
|
||||
|
||||
if (!isPaAnswerOk(nums, paAns))
|
||||
quitf(_wa, "Subsequence does not match the constraints");
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user