arrow_forward همه ارسال‌ها

جزئیات ارسال کد#827

code_blocks
مسئله مربوطه: آرایه های دوقلو (#31) arrow_outward
verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Java
schedule
ارسال‌کننده و زمان:
khashayar moeinfar (۱ سال پیش)
descriptionMain.java ۶۱ خط • ۱٫۷ کیلوبایت
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 m = sc.nextInt();
23
24 int[] arr = new int[n];
25 for (int i=0; i<n; i++){
26 arr[i]=sc.nextInt();
27 }
28
29 int[] arr2=new int[n];
30 for(int i=0;i<n;i++){
31 arr2[i]=sc.nextInt();
32 }
33 boolean flag =false;
34
35 int end = n;
36outer: for (int i =0 ;i<n;i++){
37 for (int j=0; j<end;j++){
38 if(arr2[i]==arr[j%n] && i!=n-1){
39 end = j+n+1;
40 break ;
41 }
42 else if ( arr2[i]==arr[j%n]) {
43 flag = true;
44 break outer;
45 }
46 else {
47 continue;
48 }
49 }
50 }
51
52 if (flag){
53 System.out.print("Yes");
54 }
55
56 else{
57 System.out.print("No");
58 }
59
60 }
61}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8