#P2294. [HNOI2005] 狡猾的商人
[HNOI2005] 狡猾的商人
Description
Diao Cha receives a task from the tax authority to investigate a merchant’s ledger and determine whether it is forged. The ledger records the income over months, where the income in month is , . When , it means the profit in that month is yuan; when , it means the loss in that month is yuan. The total income over a period is the sum of the monthly incomes within that period.
Her task is carried out in secret. To investigate the ledger, she goes to work for the merchant. When the merchant is away, she peeks at the ledger, but she cannot take it out. Each time she peeks, she can only look at the income recorded for some continuous period, and she can remember only the total income over that period.
Now, she has peeked at the ledger times and thus remembered the total incomes over periods. Your task is to determine, based on these remembered totals, whether the ledger is fake.
Input Format
The first line contains a positive integer , where , indicating that there are test cases (that is, ledgers) to judge.
For each test case, the first line contains two positive integers and , where , indicating how many months of income the ledger records and how many times she peeked at the ledger.
The next lines describe the pieces of information Diao Cha remembered after peeks. Each line contains three integers , and , meaning that the total income from month to month (including month ) is . Here, assume is always less than or equal to .
Output Format
Output lines, each containing true or false. The -th line is true if and only if the -th test case, i.e., the -th ledger, is not fake; the -th line is false if and only if the -th test case, i.e., the -th ledger, is fake.
2
3 3
1 2 10
1 3 -5
3 3 -15
5 3
1 5 100
3 5 50
1 2 51
true
false
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号