arrow_forward
همه ارسالها
جزئیات ارسال کد#822
برای پسندیدن وارد شوید
1////TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
2//// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
3//void main() {
4// //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
5// // to see how IntelliJ IDEA suggests fixing it.
6// IO.println(String.format("Hello and welcome!"));
7//
8// for (int i = 1; i <= 5; i++) {
9// //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
10// // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
11// IO.println("i = " + i);
12// }
13//}
14
15
16import java.util.Scanner;
17public class Main {
18 public static void main(String[] args) {
19 Scanner sc = new Scanner(System.in);
20 int n = sc.nextInt();
21 int m = sc.nextInt();
22 int[] arrBig = new int[n];
23 for (int i=0 ; i<n;i++){
24 arrBig[i] = sc.nextInt();
25 }
26 int[] arrSmall = new int[m];
27 for (int i=0 ; i<m;i++){
28 arrSmall[i] = sc.nextInt();
29 }
30 outer:
31 for (int i=0 ; i<n;i++) {
32 if (arrBig[i] == arrSmall[0] && i < n - m + 1) {
33 for (int j = 0; j < m; j++) {
34 if (arrBig[i + j] == arrSmall[j] && j < m - 1) {
35 continue;
36 } else if (arrBig[i + j] == arrSmall[j]) {
37 System.out.print("Yes");
38 break outer;
39 } else {
40 break;
41 }
42 }
43 }
44
45 if (i == n - 1) {
46 System.out.println("No");
47 }
48
49 }
50 }
51}
کد ارسالشده برای داوری خودکار هاتکدز
UTF-8