-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedu_35_4.java
More file actions
42 lines (41 loc) · 818 Bytes
/
edu_35_4.java
File metadata and controls
42 lines (41 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class edu_35_4 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int a[] = new int[n];
for(int i=0;i<n;i++)
a[i] = scan.nextInt();
int q = scan.nextInt();
while(q-->0)
{
int l = scan.nextInt();
int r= scan.nextInt();
int b[] = new int[n];
int k=0;
for(int i=0;i<l-1;i++)
b[k++]=a[i];
for(int i=r-1;i>=l-1;i--)
b[k++]=a[i];
for(int i=r;i<n;i++)
b[k++]=a[i];
int c=0;
/*for(int i=0;i<n;i++)
System.out.print(b[i]+" ");*/
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(b[i]>b[j])
c++;
}
}
//System.out.println();
//System.out.println(c);
if(c%2==0)
System.out.println("even");
else
System.out.println("odd");
}
}
}