Poll
Statement
Goal
You've established an online voting system for two candidates, labeled asFind the final results for the two candidates and print them on the same line.
Example
30
7
0 1 0 <- First vote of user 0, ok. The vote goes to 1.
0 1 15 <- Less than 30s have elapsed, ignored.
1 0 15 <- First vote by user 1, ok.
2 0 15 <- First vote by user 2, ok.
0 1 30 <- At least 30s since last vote of user 0, ok.
0 1 35 <- Less than 30s have elapsed, ignored.
1 0 50 <- At least 30s since last vote of user 1, ok.
>>> Votes of candidate 0, votes of candidate 1
>>> 3 2
Input
Line 1 : The timeout that you have decided upon, in seconds.
Line 2 : The number of entries in your database, n_entries.
Next n_entries lines: An entry, that is, three space-separated integers:
- user_id, the id of the user
- vote, the candidate that was voted
- time, the time in seconds elapsed since the system started to work.
Notes:
(1) The data is already sorted in ascending order by time.
(2) The user_ids start at0 and they increment by one for each new user.
Line 2 : The number of entries in your database, n_entries.
Next n_entries lines: An entry, that is, three space-separated integers:
- user_id, the id of the user
- vote, the candidate that was voted
- time, the time in seconds elapsed since the system started to work.
Notes:
(1) The data is already sorted in ascending order by time.
(2) The user_ids start at
Output
A line containing the number of votes of candidate 0 , then those of candidate 1 , separated with a space.
Constraints
0 < timeout <= 100
0 < n_entries <= 100
vote is0 or 1
0 <= time <= 200
0 < n_entries <= 100
vote is
0 <= time <= 200
Example
Input
30 7 0 1 0 0 1 15 1 0 15 2 0 15 0 1 30 0 1 35 1 0 50
Output
3 2
Game modes
Fastest, Shortest
Test cases
1. Example Test
Input
30
7
0 1 0
0 1 15
1 0 15
2 0 15
0 1 30
0 1 35
1 0 50
Output
3 2
1. Example val Validator
Input
30
5
0 0 0
0 0 15
1 1 15
2 1 30
0 0 45
Output
2 2
2. Timeout Test
Input
10
4
0 0 0
0 0 5
0 1 9
0 0 10
Output
2 0
2. Timeout val Validator
Input
10
4
0 1 0
0 1 7
0 0 9
0 1 10
Output
0 2
3. Different ids Test
Input
30
5
0 0 0
0 0 15
1 1 15
2 1 15
3 1 15
Output
1 3
3. Different ids val Validator
Input
30
5
0 0 0
0 0 15
1 1 45
2 0 45
3 1 45
Output
2 2
4. Random 1 Test
Input
60
10
0 0 30
1 1 30
0 0 45
2 0 45
2 0 45
1 0 60
1 0 75
1 1 120
0 1 135
2 0 135
Output
3 3
4. Random 1 val Validator
Input
60
10
0 1 15
1 1 15
0 1 60
2 1 60
0 1 90
2 1 90
0 0 105
0 1 150
0 1 150
2 1 150
Output
0 6
5. Random 2 Test
Input
10
100
0 1 2
1 1 5
2 1 7
3 1 7
1 0 7
4 1 7
5 1 10
6 0 12
7 1 12
8 0 15
9 0 15
10 0 17
11 1 17
12 1 20
10 1 20
13 0 20
14 0 20
14 0 20
15 1 20
16 1 20
11 0 22
17 1 27
18 0 30
19 0 32
20 1 32
21 0 32
22 1 35
14 1 35
20 0 37
23 0 37
11 1 37
16 1 37
20 1 40
24 0 42
24 0 45
13 1 45
25 0 45
21 1 45
26 1 45
27 0 47
16 0 47
20 1 50
20 0 50
6 1 52
28 0 52
28 1 52
25 0 52
26 0 52
12 0 55
29 1 55
9 0 55
30 0 57
25 0 57
31 1 57
32 1 60
28 1 62
22 1 65
25 0 65
32 0 65
21 0 65
16 1 65
33 0 67
3 1 70
17 1 70
4 1 70
32 0 70
34 0 72
12 0 72
35 1 72
10 0 72
29 0 72
36 0 72
21 1 72
19 0 75
37 1 75
11 1 75
17 0 77
38 1 80
9 1 80
5 1 82
32 1 82
39 0 82
22 1 85
6 0 85
6 1 87
29 0 87
29 1 87
5 0 87
40 1 87
40 0 90
27 1 92
3 1 95
41 0 95
23 1 95
42 1 97
41 1 97
43 1 97
30 1 100
33 1 100
25 1 100
Output
32 48
5. Random 2 val Validator
Input
10
100
0 0 2
1 0 5
2 1 7
3 0 7
4 1 7
5 1 7
6 0 7
7 1 10
8 1 10
9 0 10
10 1 12
6 0 12
6 1 12
9 1 12
0 1 17
11 1 17
9 1 17
12 1 22
13 0 25
14 1 25
15 1 27
16 1 27
17 0 27
7 1 30
13 1 32
18 0 32
11 0 32
19 0 35
20 1 35
12 1 35
21 1 37
22 1 37
23 1 37
13 0 37
24 1 37
7 1 40
24 0 40
11 0 40
25 1 40
15 1 42
26 1 42
6 1 42
25 0 42
10 1 45
10 1 45
27 1 45
17 1 45
22 0 47
24 1 50
28 1 50
21 1 52
8 0 52
29 0 52
30 1 52
21 0 55
13 1 55
14 0 55
29 1 57
31 1 57
8 0 60
32 1 60
19 0 62
10 1 62
18 0 62
11 0 62
28 1 62
33 0 65
16 0 65
0 1 65
34 0 65
12 0 65
35 0 67
36 0 67
37 0 70
0 0 70
38 1 72
31 1 75
31 1 75
31 0 75
17 1 75
39 0 77
35 1 80
27 1 80
40 0 82
29 0 82
41 1 82
9 1 82
42 1 85
16 1 87
38 0 87
17 1 87
21 0 90
20 0 90
28 1 90
9 0 90
23 1 95
0 1 95
43 1 97
30 1 97
29 1 100
Output
31 53
6. Random draw Test
Input
10
100
0 0 5
1 0 5
2 0 7
3 0 10
4 1 10
5 0 12
6 0 12
7 0 12
8 0 12
9 1 12
10 0 12
4 1 12
11 1 17
12 0 17
13 1 17
11 0 20
13 0 20
13 1 20
7 1 22
14 1 22
15 1 25
2 1 25
16 1 30
17 0 30
18 1 30
19 0 32
12 0 32
14 0 32
13 0 32
20 0 35
21 0 35
22 1 35
8 0 35
9 1 37
23 1 37
24 1 37
15 0 40
19 1 42
7 0 42
25 1 45
26 1 47
19 0 50
14 0 50
9 1 50
11 1 52
5 1 52
5 0 55
27 1 55
9 0 57
4 1 57
25 1 57
28 1 57
29 1 60
30 1 60
31 1 60
32 0 60
32 0 60
7 0 62
33 0 65
11 0 65
34 0 65
4 0 65
35 0 65
3 1 67
1 0 67
29 1 70
17 0 70
18 1 70
36 0 72
24 1 72
13 0 72
21 0 75
24 0 75
25 1 75
16 1 77
20 1 77
21 0 77
37 1 77
23 1 77
38 0 80
39 0 80
9 1 80
28 1 80
18 1 85
14 0 85
2 0 85
9 0 85
23 1 85
40 0 87
18 1 87
20 1 90
37 1 90
18 0 90
15 1 92
34 0 95
19 0 97
10 0 97
26 0 100
26 1 100
37 0 100
Output
42 42
6. Random draw val Validator
Input
10
100
0 0 2
1 1 2
1 0 2
2 0 5
3 1 5
4 1 5
5 0 5
6 1 7
7 1 7
8 0 10
9 1 10
10 0 10
7 1 10
11 1 12
12 1 12
13 0 12
8 0 15
6 1 15
14 0 15
15 1 15
16 1 15
17 1 15
17 0 17
18 1 20
19 0 20
20 1 22
21 0 25
16 0 25
17 1 25
18 1 27
15 1 27
22 0 27
23 0 30
24 0 30
11 1 32
25 1 32
19 1 32
26 1 32
27 0 35
28 0 35
29 0 35
30 1 35
5 0 35
31 0 37
32 0 40
33 0 40
26 0 40
8 1 45
23 1 45
26 1 45
34 0 47
22 0 50
34 1 52
35 0 55
8 0 55
34 0 55
0 0 55
14 1 55
21 0 55
7 0 60
35 0 62
27 1 62
23 1 62
36 1 62
33 1 62
35 0 65
32 0 65
37 1 65
38 0 67
2 0 67
10 0 67
20 0 67
20 1 67
27 0 70
32 0 72
3 0 72
12 1 72
29 1 72
5 1 72
32 1 75
12 1 75
39 0 75
40 1 77
15 1 77
41 0 77
4 1 80
7 0 80
36 0 80
31 0 80
9 0 82
9 1 85
24 1 85
5 1 85
11 1 87
9 0 90
18 1 92
33 1 95
40 0 97
7 0 97
31 1 100
Output
42 42
Solution language
Solution
Stub generator input