-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1109.cpp
More file actions
44 lines (35 loc) · 900 Bytes
/
1109.cpp
File metadata and controls
44 lines (35 loc) · 900 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
42
43
44
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace std;
char valida(string palavra, vector<string> &expressao){
if(palavra == expressao[0]) return 'Y';
else return 'N';
}
// TODO terminar
int main(){
string regex, subRegex, palavra;
vector<string> expressao;
stack<char> aux;
int testes;
while(getline(cin, regex)) {
for(int i=0; i<regex.size(); i++) {
if(regex[i] == '(') {
aux.push('(');
} else if (regex[i] == ')') {
aux.pop();
expressao.push_back(subRegex);
} else {
subRegex += regex[i];
}
}
cin >> testes;
for(int j=0; j<testes; j++) {
cin >> palavra;
char v = valida(palavra, expressao);
cout << v << endl;
}
}
return 0;
}