-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_view.cpp
More file actions
41 lines (32 loc) · 770 Bytes
/
04_view.cpp
File metadata and controls
41 lines (32 loc) · 770 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<char, int>> dq;
vector<char> mount;
vector<char> sea;
pair<char, int> p;
int cur = 0;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p.first >> p.second;
dq.push_back(p);
}
for (auto p : dq) {
if (p.second > cur) {
mount.push_back(p.first);
cur = p.second;
}
}
cur = 0;
for (auto it = dq.end() - 1; it >= dq.begin(); it--) {
if (it->second > cur) {
sea.insert(sea.begin(), it->first);
cur = it->second;
}
}
for (auto i : mount) cout << i << " ";
cout << "\n";
for (auto i : sea) cout << i << " ";
}