arrow_forward
همه ارسالها
جزئیات ارسال کد#568
برای پسندیدن وارد شوید
1#include <iostream>
2using namespace std;
3int main()
4{
5 int n , m;
6 cin >> n >> m;
7 int Arr[n] , arr[m];
8
9 for ( int i = 0 ; i < n ; i ++ )
10 {
11 cin >> Arr[i];
12 }
13
14 for ( int i = 0 ; i < m ; i ++ )
15 {
16 cin >> arr[i];
17 }
18
19 int indx1 = 0;
20 int indx2 = 0;
21 int counter = 0;
22 while ( indx2 < m )
23 {
24 if ( Arr[indx1] == arr[indx2] )
25 {
26 indx2 ++;
27 }
28
29 else
30 {
31 counter ++;
32
33 if ( counter >= n*m )
34 {
35 break;
36 }
37 }
38
39 if ( indx1 == n - 1 )
40 {
41 indx1 = 0;
42 }
43
44 else
45 {
46 indx1 ++;
47 }
48 }
49
50 if ( indx2 == m )
51 {
52 cout << "Yes";
53 }
54
55 else
56 {
57 cout << "No";
58 }
59
60
61 return 0;
62}
کد ارسالشده برای داوری خودکار هاتکدز
UTF-8