From ebe09cf0adac1fafa3753e6986ad40b1598f1404 Mon Sep 17 00:00:00 2001
From: cuom1999
Date: Wed, 20 Apr 2022 14:04:06 -0500
Subject: [PATCH] Update custom checker sample
---
templates/about/custom-checker-sample.html | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/templates/about/custom-checker-sample.html b/templates/about/custom-checker-sample.html
index 713a894..0f3819a 100644
--- a/templates/about/custom-checker-sample.html
+++ b/templates/about/custom-checker-sample.html
@@ -160,6 +160,7 @@ main.exe [input_file]
0 nếu AC (100% điểm)
1 nếu WA (0 điểm)
+ Thông tin được in ra trong stderr (bằng cerr) sẽ là feedback hiển thị cho người dùng.
Ví dụ:
@@ -168,6 +169,11 @@ main.exe [input_file]
#include <bits/stdc++.h>
using namespace std;
+void quit(string reason) {
+ cerr << reason << endl;
+ exit(1);
+}
+
void read(long long& guess) {
if (!(cin >> guess)) exit(1); // Nếu không có dòng này, chương trình sẽ chờ vô hạn
if (guess < 1 || guess > 2e9) exit(1);
@@ -179,7 +185,7 @@ int main(int argc, char *argv[]) {
long long guess;
inp >> N;
- while (guess != N && guesses < 31) {
+ while (guess != N && guesses <= 31) {
read(guess);
if (guess == N) {
cout << "HOLA" << endl;
@@ -190,10 +196,11 @@ int main(int argc, char *argv[]) {
}
guesses++;
}
-
+ cerr << "Number of used guesses: " << guesses << endl;
if (guesses <= 31)
return 0; // AC
else {
+ cerr << "Used too many guesses" << endl;
return 1; // WA
}
}