题目描述
Background
This is a hack problem. In this problem, you will be given two questions and two pieces of code that solve the respective problems. However, the provided code does not produce correct outputs for certain inputs. Incorrect outputs include:
- Outputting wrong results.
- Exceeding the time limit.
- Producing runtime undefined behavior, which currently only includes array out-of-bounds errors detectable by technology.
For this problem, you need to submit an input dataset that meets the requirements, causing the given code to fail to produce the correct output. You can use the 'Submit Answer' feature directly or submit a data generator written in any language.
Each question is worth $50$ points, totaling $100$ points.
Hint: If you use the Submit Answer feature, remember to switch the language back to the one you are using when submitting other problems.
Problem Description
Below are the descriptions of the two questions:
Question 1
Given integers $a, b, c$, compute the value of $\left\lceil\dfrac{a}{b - c}\right\rceil$, where $\left\lceil x \right\rceil$ represents the smallest integer not less than $x$.
Question 2
std::cerr is an output tool that sends output to the standard error stream. If you run the following program:
#include <iostream>
int main() {
std::cerr << "Hello Luogu!" << std::endl;
}
You will find that Hello Luogu! is printed in the command line/cmd; however, if you add freopen("text.txt", "w", stdout) at the beginning of the main function and run the program, then open text.txt, you will find the file is empty, while Hello Luogu! is still printed in the command line/cmd.
Thus, std::cerr has an important application in algorithmic competitions: using std::cerr to output intermediate variables, which are printed on the screen but not in the output file/standard output. Additionally, std::cerr has the effect of flushing the buffer. Previously, once a Runtime Error occurred, any content printed to stdout that was still in the buffer would not be output. Using std::cerr does not have this issue because it flushes the buffer content directly to the standard error stream after each output.
For example, you can try running the following code locally:
#include <iostream>
int main() {
std::ios::sync_with_stdio(false);
std::cout << "Hello Luogu!\n";
int x = *((int*)0);
}
On most machines, nothing will be printed on the screen before the application aborts abnormally. This situation is not conducive to debugging because it is impossible to determine which statement caused the program to terminate. However, if you replace std::cout with std::cerr and run the program again, you will find that Hello Luogu! is printed on the screen before the program aborts. Note that flushing the buffer is a slow operation. If the buffer is flushed too frequently, it can cause the program to time out.
In the recently concluded ICPC Shandong Provincial Competition, Fusu attempted to use std::cerr for debugging on Problem K. However, in her submission at 4 hours and 59 minutes, she had already written the correct code but forgot to remove the std::cerr debugging statements. Although this did not cause her to output extra information to the contestants, due to excessive buffer flushing, her submission was judged as TIME LIMIT, causing her to miss the provincial championship.


(Calculations show that if the fourth attempt on Problem K had passed, 'Four-hour Workday' would have won by an 8-minute penalty advantage)
Therefore, for a string, she feels that if the string contains std::cerr as a substring, it is 'not very good'; otherwise, she thinks the string is 'very good'.
Given $T$ strings, please determine if they are 'not very good'.
Input and Output Format
Input Format
Question 1
The input consists of a single line with three integers: $a$, $b$, and $c$.
Question 2
The first line is an integer representing the number of input strings, $T$.
The next $T$ lines each contain a string that needs to be judged.
In Question 2, the input must not have trailing spaces at the end of the lines. However, it can have a trailing newline at the end of the file.
Output Format
Question 1
Output a single line with an integer representing the answer.
Question 2
Output a single line with an integer representing the number of strings that are 'not very good'.
Sample Input and Output
Sample Input #1
9 8 5
Sample Output #1
3
Sample Input #2
3
std::cerr
std::cerr<<"HelloLuogu!";
std::cout<<"HelloLuogu!";
Sample Output #2
2
Notes
Sample Group and Actual Input Explanation
The two samples correspond to the sample input and output for the two questions.
If you directly use the 'Submit Answer' method, please name the two input data files as 1.in and 2.in, and compress them into a zip file for submission.
If you use a data generator, your generator can read an integer $x$ from standard input, where $1 \leq x \leq 2$, representing the problem number for the test point, and then output the corresponding input data.
Obviously, your program should not read any content mentioned in the 'Input Format', nor should it output any content mentioned in the 'Sample Output'. You should not use the samples to test your program; these are just examples for the two questions.
Data Scale Requirements
The data you provide must meet the following requirements:
- Fully comply with the 'Input Format' regulations, without any extra input, but can have a trailing newline. Question 1 can have trailing spaces at the end of the line.
- For Question 1, $1 \leq a, b, c \leq 100$, $b \neq c$.
- For Question 2, $1 \leq T \leq 10^6$, the total length of the input strings does not exceed $2 \times 10^6$, and no input string can be empty, containing only visible characters (ASCII values between $33$ and $126$, spaces are not considered visible characters).
Target Code
You need to hack the following code:
Question 1
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int d = b - c;
cout << ((a + d - 1) / d) << endl;
}
Question 2
#include <iostream>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
std::string s;
int ans = 0, cur = 0;
for (std::cin >> T; T; --T) {
std::cin >> s;
++cur;
if (s.find("std::cerr") != std::string::npos) {
std::cerr << cur << '\n';
++ans;
}
}
std::cout << ans << std::endl;
}
The compilation options for the target code are -std=c++14 -fno-asm -O2. The compiler is the g++ provided by Luogu. You can select the C++14 language in the 'Online IDE' to get the same compilation environment.
Data Judgment
The data you provide must fully comply with the 'Data Scale Requirements', otherwise, it will result in an Unaccepted outcome.
Time Limit Judgment
The program's execution time is monitored periodically. We guarantee that the number of instructions between two checks is a quantity unrelated to the input scale, i.e., $O(1)$ instructions are checked. The number of instructions between two checks is not too many, generally no more than $100$ C++ statements.
If the program's execution time exceeds $500 \text{ms}$, it is judged as exceeding the time limit, returning an accepted result.
Incorrect Result Judgment
If the program ends within the specified time and produces an output, we will compare this output with the completely correct output. If they differ, it is judged as a successful hack, returning an accepted result.
Undefined Behavior Judgment
We will check if the array index exceeds the array range before each explicit array element access. If it exceeds, it is judged as a successful hack, returning an accepted result.
This means that if you want to hack through undefined behavior, you can only hack explicit array element access.
Sample Program
This is a sample program to help you understand what you need to output, but it cannot produce correct hack data. Submitting this program directly will not earn points.
#include <iostream>
using namespace std;
int main() {
int taskId;
cin >> taskId;
if (taskId == 1) {
cout << "" <<endl;
} else if (taskId == 2) {
cout << "" << endl;
} else { // This else will not be executed
cout << "Stupid Fusu!" << endl;
}
}
If you use the 'Submit Answer' feature, ensure that opening the compressed package directly shows only the two .in files. This means the file structure must be:
ans.zip
|---1.in
|---2.in
The files should not be contained in an additional folder, i.e., the file structure should not be:
ans.zip
|---ans(folder)
|---1.in
|---2.in
About Evaluation Information
If the hack is successful, the corresponding test point information is accepted. If other information is returned, it indicates that the program itself has errors.
For example, if TLE is returned, it does not mean that the corresponding program was successfully hacked to exceed the time limit, but rather that the data generator itself exceeded the time limit, and the test point does not earn points.
Particularly, returning UKE results may indicate illegal data (extra content, missing content, or data range not meeting requirements).
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分