Sign in
or
Register
Courses
Textbook
Compiler
Contests
Topics
Courses
Algorithms
two pointers
Module:
two pointers
Problem
3
/11
Two identical arrays
Problem
The input is two arrays
A
and
B
, sorted in non-descending order. You need to find out if there exists a number that is contained in both arrays. If such a number exists, print 1, otherwise print 0.
Input
The first line contains the natural numbers N and M– the number of elements of the first and second array respectively, (1 <= N, M <= 1e8). The next two lines contain the elements of the array A and B. The second line contains the elements of the array A, the third contains the elements of the array B. All elements of the array are non-negative numbers not exceeding 10
18
.
Imprint
Print the answer to the problem.
Examples
#
Input
Output
1
4 4
1 2 3 4
2 4 7 8
1
2000
ms
256 Mb
Rules for program design and list of errors in automatic problem checking
Teacher commentary