QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22656. Bestiame bugiardo

Statistics

C’è sempre una piantagrane. Farmer John sa che tra $N$ mucche ($1 \le N \le 100$, numeri1 a $N$), una mente sempre e le altre dicono sempre vero. Per trovarla presto visita le mucche al pascolo una a una e fa $Q$ domande semplici ($1 \le Q \le 1{,}000$) sul cibo (oneste ma poco intelligenti, capiscono pochi temi come il cibo). Annota così:

Mucca4 dice che5 mangia più erba di10. Mucca6 dice che10 mangia più di7. Mucca3 dice che2 mangia più di6. Mucca1 dice che7 mangia più di5.

Sopra la bugiarda è4, 6 o1. Trova il numero di «potenziali bugiarde», che potrebbero essere l’unica bugiarda secondo i dati.

Input

  • Riga1: due interi separati da spazio $N$, $Q$.
  • Righe $2..Q+1$: ogni risposta ha3 interi separati da spazi $A$, $B$, $C$; mucca $A$ dice che $B$ mangia più erba di $C$. La stessa mucca può apparire più volte.

Output

  • Riga1: un intero, numero di potenziali bugiarde.

Esempi

Input 1

3 4
3 1 2
1 3 1
1 3 2
2 2 1

Output 1

2

Nota

Dettagli dell’ingresso

3 mucche danno4 risposte:1 dice che3 mangia più di1 e2;2 dice che2 più di1;3 dice che1 più di2 (confronto di cibo mangiato).

Dettagli dell’uscita

2 o3 mente perché le frasi sono opposte. Se1 mentisse,2 e3 non potrebbero mentire, dunque1 dice vero.

Autore del problema: Brian Dean, 2004

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.