-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chef_and_Meetings.cpp
85 lines (67 loc) · 1.71 KB
/
Chef_and_Meetings.cpp
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
// www.codechef.com/FEB21C/problems/MEET/
#include <bits/stdc++.h>
using namespace std;
class CTime {
public:
int hh;
int mm;
char M;
int total;
void calT() {
if (M == 'A' && hh == 12) {
hh -= 12;
}
if (M == 'P' && hh != 12) {
hh +=12;
}
total = hh*60 + mm;
}
};
class FTime {
public:
CTime Arr, Dep;
};
char* subchar(char *str, int pos) {
char *anschar = new char[2];
anschar[0] = str[pos];
anschar[1] = str[pos+1];
return anschar;
}
void solution() {
int n;
char time_str[20];
CTime chef;
cin.getline(time_str, 10);
chef.M = time_str[6];
chef.hh = atoi(subchar(time_str, 0));
chef.mm = atoi(subchar(time_str, 3));
chef.calT();
cin >> n;
int ans[n] = {0}, k = 0;
FTime friends[n];
cin.ignore();
for (int i = 0; i < n; i++) {
cin.getline(time_str, 20);
friends[i].Arr.M = time_str[6];
friends[i].Arr.hh = atoi(subchar(time_str, 0));
friends[i].Arr.mm = atoi(subchar(time_str, 3));
friends[i].Arr.calT();
friends[i].Dep.M = time_str[15];
friends[i].Dep.hh = atoi(subchar(time_str, 9));
friends[i].Dep.mm = atoi(subchar(time_str, 12));
friends[i].Dep.calT();
if (chef.total >= friends[i].Arr.total && chef.total <= friends[i].Dep.total) ++ans[i];
}
for (int i = 0; i < n ;i++) cout << ans[i];
cout << endl;
}
int main() {
ios_base::sync_with_stdio(0);
int test;
cin >> test;
cin.ignore();
while (test--) {
solution();
}
return 0;
}