forked from konradbachusz-zz/HackerRank_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attribute_parser.cpp
61 lines (51 loc) · 1.11 KB
/
attribute_parser.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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <regex>
using namespace std;
int main() {
int n,q;
vector<string> markup;
cin >> n;
cin >> q;
cin.ignore();
//Get markup
for(int i = 0; i <n/2; i++)
{
string local;
getline(cin, local);
markup.push_back(local);
}
//Skip endtags
for(int i = 0; i <n/2; i++)
{
string end_tag;
getline(cin, end_tag);
}
// cout <<"Query"<< endl;
vector<string> query;
//Get queries
for(int i = 0; i <q; i++)
{
string local;
getline(cin, local);
query.push_back(local);
//cout << query[i]<<endl;
}
//Run Query
for(int i = 0; i <query.size(); i++)
{
int size_t;
regex r("~\\w*d*");
smatch m;
size_t = count(query[i].begin(), query[i].end(), '.');
//cout<< size_t<<endl;
regex_search(query[i], m, r);
for (auto x : m)
cout << x <<endl;
}
return 0;
}