Trở về đầu
Dịch lại trên cmd và load lại Bài nộp trên Themis
Sử dụng file trên github Download tại đây rồi vào cmd chạy lệnh sau (thêm trường DTHEMIS mới chấm được):
g++ -std=c++17 -O2 -Wall -static -s -DTHEMIS checkLIS.cpp -o checkLIS.exe
Chú ý: Tên file check = check + tên bài Themis: chạy ở chế độ chấm C7
hoặc: Cách 2: Cấu hình trực tiếp trên Codeblocks có #define THEMIS: Settings > Compiler > ... > defines: thêm chữ THEMIS (viết hoa)
Code của checkLIS như sau:
#include "testlib_themis_cms.h"
#include
using namespace std;
int main(int argc, char* argv[]) {
#ifdef THEMIS
registerTestlibThemis("LIS.INP", "LIS.OUT"); // thay max = mã bài
#else
registerTestlibCmd(argc, argv);
#endif // THEMIS
// Doc du lieu dau vao.
const int n = inf.readInt(1, 1000000, "n");
vector a(n);
for (int i = 0; i < n; ++i) {
a[i] = inf.readLong();
}
// Checker chi can do dai toi uu trong dap an chuan. Day LIS cu the
// trong LIS.OUT khong duoc dung de ep thi sinh phai in cung mot day.
const int optimalLength = ans.readInt(1, n, "optimalLength");
// Doc ket qua cua thi sinh.
const int claimedLength = ouf.readInt(0, n, "claimedLength");
/// Kiem tra do dai 2 day con co khop nhau khong ?
if (claimedLength != optimalLength) {
quitf(_wa, "Expected LIS length %d, but contestant reported %d.",
optimalLength, claimedLength);
} else {
setMinimumPoint(0.5); /// Cho diem 50% cua test do. Vi du: test 1 diem thi hoc sinh duoc toi thieu 0.5 diem
setMessageNote("* Ket qua da dung do dai day con.");
}
/// Doc tiep ket qua day con tim duoc cua hoc sinh
vector sequence(claimedLength);
for (int i = 0; i < claimedLength; ++i) {
sequence[i] = ouf.readLong();
}
if (!ouf.seekEof()) {
quitf(_wa, "Output contains extra data after %d sequence elements.",
claimedLength);
}
// Kiem tra day tang nghiem ngat.
for (int i = 1; i < claimedLength; ++i) {
if (sequence[i - 1] >= sequence[i]) {
quitf(_wa,
"Sequence is not strictly increasing at positions %d and %d: "
"%lld >= %lld.",
i, i + 1, sequence[i - 1], sequence[i]);
}
}
// Kiem tra day thi sinh in ra co thuc su la day con cua a hay khong.
int matched = 0;
for (int i = 0; i < n && matched < claimedLength; ++i) {
if (a[i] == sequence[matched]) {
++matched;
}
}
if (matched != claimedLength) {
quitf(_wa,
"The reported sequence is not a subsequence of the input; "
"only the first %d of %d elements can be matched.",
matched, claimedLength);
}
quitf(_ok, "Valid LIS of optimal length %d.", optimalLength);
}