-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathbuilding_walls.cpp
58 lines (44 loc) · 1014 Bytes
/
building_walls.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
// https://www.urionlinejudge.com.br/judge/pt/problems/view/2650
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
vector<string> split(string s) {
vector<string> V;
int startIndex = 0;
for (int i = 1; i < s.size(); i++) {
if (s[i] == ' ') {
V.push_back(s.substr(startIndex, i+1));
startIndex = i+1;
}
V.push_back(startIndex, s.size() - startIndex);
}
return V;
}
int to_digit(string height) {
int digit = 0;
for (int i = 0; i < height.size(); i++) {
digit += (height[i] - '0') * pow(10, height.size() - 1 - i);
}
return digit;
}
int main() {
int N, W, H;
string titan, name, line, height;
vector<string> V;
cin >> N >> W;
cin.ignore();
while (N--) {
getline(cin, line);
V = split(line);
height = V.pop_back();
H = to_digit(height);
if (H > W) {
for (int i = 0; i < V.size()-1; i++) cout << V[i] << " ";
cout << V[i] << endl;
}
V.clear();
}
return 0;
}