-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtime-table.cpp
40 lines (36 loc) · 924 Bytes
/
time-table.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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
const int N = 2e5 + 11;
void solve() {
int start_hour, start_min, end_hour, end_min;
cin >> start_hour >> start_min >> end_hour >> end_min;
bool hour_adjust = false;
int duration_min = abs(end_min - start_min);
if (start_min > end_min) {
hour_adjust = true;
duration_min = 60 - duration_min;
}
int duration_hour = abs(end_hour - start_hour);
if (hour_adjust) {
if (start_hour > end_hour) duration_hour++;
else duration_hour--;
}
if (start_hour > end_hour)
duration_hour = 12 - duration_hour;
cout << duration_hour << " " << duration_min << endl;
}
int main() {
freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int no_of_test_cases = 1;
cin >> no_of_test_cases;
while (no_of_test_cases--)solve();
return 0;
}