-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreedcounting.java
More file actions
112 lines (99 loc) · 2.25 KB
/
breedcounting.java
File metadata and controls
112 lines (99 loc) · 2.25 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
ID: grifync1
LANG: JAVA
PROG: breedcounting
*/
//lil lil peezy
import java.util.*;
import java.io.*;
public class breedcounting {
public static int conv(String s) {
return Integer.parseInt(s);
}
public static int max(int a, int b) {
return Math.max(a, b);
}
public static int min(int a, int b) {
return Math.min(a, b);
}
public static void print(int num) {
System.out.println(num);
}
public static void prints(String s) {
System.out.println(s);
}
public static void printa(int[] a) {
for (int i = 0; i < a.length; i++) {
if (i == 0) {
System.out.print(a[i]);
} else {
System.out.print(" " + a[i]);
}
}
}
public static int[] sort(int[] nums) {
Arrays.sort(nums);
return nums;
}
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("bcount.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("bcount.out")));
//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//PrintWriter out = new PrintWriter(System.out);
//StringTokenizer st = new StringTokenizer(in.readLine());
StringTokenizer st = new StringTokenizer(in.readLine());
int n = conv(st.nextToken());
int q = conv(st.nextToken());
int[] nums = new int[n];
int[] holst = new int[n];
int[] guern = new int[n];
int[] jer = new int[n];
for(int i=0; i<n; i++) {
nums[i] = conv(in.readLine());
}
if(nums[0]==1)
holst[0]=1;
else if(nums[0]==2)
guern[0]=1;
else
jer[0]=1;
for(int i=1; i<nums.length; i++) {
if(nums[i]==1) {
holst[i]=1+holst[i-1];
guern[i]=guern[i-1];
jer[i]=jer[i-1];
}
else if(nums[i]==2) {
holst[i]=holst[i-1];
guern[i]=1+guern[i-1];
jer[i]=jer[i-1];
}
else if(nums[i]==3) {
holst[i]=holst[i-1];
guern[i]=guern[i-1];
jer[i]=1+jer[i-1];
}
}
for(int i=0; i<q; i++) {
int h = 0;
int g = 0;
int j = 0;
st = new StringTokenizer(in.readLine());
int s = conv(st.nextToken());
int e = conv(st.nextToken());
if(s==1) {
h=holst[e-1];
g = guern[e-1];
j=jer[e-1];
}
else {
h=holst[e-1]-holst[s-2];
g=guern[e-1]-guern[s-2];
j=jer[e-1]-jer[s-2];
}
out.println(h+" "+g+" "+j);
}
in.close();
out.close();
}
}