-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcont C.cpp
More file actions
71 lines (64 loc) · 1.44 KB
/
Copy pathcont C.cpp
File metadata and controls
71 lines (64 loc) · 1.44 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
//#include <bits/stdc++.h>
//using namespace std;
//
//bool sortBySecond(const pair<string, int> &a, const pair<string, int> &b) {
// return a.second < b.second;
//}
//
//int main() {
// int a, b, c;
// string str;
// string s,s1,s2;
// int num;
// int n;
// cin >> n;
//
// vector<pair<string, int>> vp;
//
// for (int i = 0; i < n; i++) {
//
// cin >> a >> b >> c;
// num = (a*3600)+(b*60)+c;
// s=to_string(a);
// s1=to_string(b);
// s2=to_string(c);
// str=s+" "+s1+" "+s2;
// vp.push_back({str, num});
// }
// sort(vp.begin(), vp.end(), sortBySecond);
//
//
//
// return 0;
//}
//
//
#include <bits/stdc++.h>
using namespace std;
bool sortBySecond(const pair<string, int> &a, const pair<string, int> &b) {
return a.second < b.second;
}
int main() {
int a, b, c;
string str;
string s,s1,s2;
int num;
int n;
cin >> n;
vector<pair<string, int>> vp;
for (int i = 0; i < n; i++) {
cin >> a >> b >> c;
num = (a * 3600) + (b * 60) + c;
s = to_string(a);
s1 = to_string(b);
s2 = to_string(c);
str = s + " " + s1 + " " + s2;
vp.push_back({str, num});
}
sort(vp.begin(), vp.end(), sortBySecond);
// Printing the vector of pairs
for (auto &p : vp) {
cout << p.first << endl;
}
return 0;
}