arrow_forward
همه ارسالها
جزئیات ارسال کد#825
برای پسندیدن وارد شوید
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
22 int[] arr = new int[n];
23 for (int i=0; i<n; i++){
24 arr[i]=sc.nextInt();
25 }
26 int m = sc.nextInt();
27 int[] arr2=new int[m];
28 for(int i=0;i<m;i++){
29 arr2[i]=sc.nextInt();
30 }
31 boolean flag =false;
32
33outer: for (int i =0 ;i<n;i++){
34 for (int j=0; j<m;j++){
35 if(arr2[j]==arr[(i+j)%n] && j!=m-1){
36 continue;
37 }
38 else if ( arr2[j]==arr[(i+j)%n]) {
39 flag = true;
40 break outer;
41 }
42 else {
43 break;
44 }
45 }
46 }
47
48 if (flag){
49 System.out.print("Yes");
50 }
51
52 else{
53 System.out.print("No");
54 }
55
56 }
57}
کد ارسالشده برای داوری خودکار هاتکدز
UTF-8