SMPSEQ5 - Fun with Sequences (Act 3)


You are given a sequence of n integers S = s1, s2 ... sn and a sequence of m integers Q = q1, q2 ... qm.

Please print in ascending order all such i, that si = qi, i<=n, i<=m.

Input data specification

In the first line you are given one integer 2 <= n <= 100, and in the following line n integers:
-100 <= si <= 100, si <= si+1.

In the third line you are given one integer 2 <= m <= 100, and in the following line m integers:
-100 <= qi <= 100, qi <= qi+1.

Output data specification

The sequence of requested indexes separated by spaces.

Example 1

Input:
5
-2 -2 -1 1 4 
6
-3 -2 -1 1 2 3

Output:
2 3 4

Example 2

Input:
5
-2 -1 -3 1 4 
5
-3 -2 -1 1 2

Output:
4

hide comments
abhyudais: 2021-12-05 05:45:06

i am getting nzec error in java, the code is running well on my ide

Last edit: 2021-12-05 05:45:30
kuszi: 2021-06-22 12:25:16

One more example was added to the problem description

dharsan_s5: 2020-09-19 03:22:45

Not for java but same LOgic is accepted in C++

ani1000: 2019-08-02 13:29:48

spoj is so tough that sometimes I fell like commiting suicide

samadkhan: 2018-11-18 17:27:18

the sequences are sorted

danda1234: 2018-10-13 19:33:02

i dont get

hsakiv220290: 2018-01-11 05:13:25

input is not matching to previous inputs in the order of the problem.

sabbirnoncoder: 2017-05-20 11:30:55

Thank you . gary771016

kass_97: 2017-01-13 10:36:17

Yes, the index needs to be printed and starts from 1, that's all you need to know.....very easy

arphox: 2016-12-02 11:50:58

Beware, I got NZEC errors in C# because there may be empty spaces between numbers or after the last number.
So e.g.: (space is marked as _)
Input:
5
-2_-2_-1_1_4_
6
-3_-2_-1_1_2_3_

I think this can happen since when I added the StringSplitOptions.RemoveEmptyEntries to my string.Split(), it got AC immediately.

Have fun coding!


Added by:kuszi
Date:2013-11-14
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64