QOJ.ac

QOJ

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

#23885. Elementi comuni

Statistics

Testo del problema

Ti vengono date una sequenza di interi $A = (A_{1}, A_{2}, \dots, A_{N})$ di lunghezza $N$ e una sequenza di interi $B = (B_{1}, B_{2}, \dots, B_{M})$ di lunghezza $M$. Stampa tutti gli interi che compaiono sia in $A$ che in $B$, $1$ volta ciascuno, in ordine crescente.

Vincoli

  • $1 \le N \le 100$.
  • $1 \le M \le 100$.
  • $1 \le A_{i} \le 100$ ($1 \le i \le N$).
  • $1 \le B_{j} \le 100$ ($1 \le j \le M$).

Dati di input

L'input è fornito dallo standard input nel seguente formato:

N M
A_1 A_2 ... A_N
B_1 B_2 ... B_M

Dati di output

Stampa tutti gli interi che compaiono sia in $A$ che in $B$, $1$ volta ciascuno, in ordine crescente. Separa gli interi andando a capo.

Esempi di input e output

Input di esempio 1

6 5
2 4 6 8 10 12
15 12 9 6 3

Output di esempio 1

6
12
  • $6$ compare al $3$° posto di $A$ e al $4$° posto di $B$. Inoltre, $12$ compare al $6$° posto di $A$ e al $2$° posto di $B$. Non esistono altri interi oltre a $6$ e $12$ che compaiono in entrambi $A, B$. Pertanto, si stampano $6, 12$ in ordine crescente separati da un a capo.

Input di esempio 2

3 5
100 100 100
100 100 100 100 100

Output di esempio 2

100
  • $100$ compare in entrambi $A, B$. Non esistono altri interi oltre a $100$ che compaiono in $A, B$. Pertanto, si stampa $100$.

Input di esempio 3

1 1
2
5

Output di esempio 3

```

- Non esiste alcun intero che compare in entrambi $A, B$. Pertanto, non si stampa nulla.

---

#### Input di esempio 4

10 10 76 91 98 7 98 7 98 10 63 91 70 71 10 10 91 70 65 10 63 76

#### Output di esempio 4

10 63 76 91 ```

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.