You are viewing a single comment's thread. Return to all comments →
using namespace std;
int main() { int n , q ; map mp; std::deque stack; cin >> n >> q;
for (int i = 0; i < n; i++) { string tag , val , key ; cin >> tag; tag.erase(0,1); if ( tag[0] != '/' && tag[tag.length()-1] =='>') { tag.erase(tag.length()-1,1); stack.push_back(tag); } else if(tag[0] != '/' && tag[tag.length()-1] != '>') { stack.push_back(tag); cin >> val; cin.ignore(10,'"'); cin >> key; string tagStr ; for (auto &i:stack) { tagStr.append(i); if (i != stack.back()) { tagStr.append("."); } } while (key[key.length()-1] != '>') { string tag1 = tagStr; tag1.append("~"); tag1.append(val); key.erase(key.length()-1,key.npos); mp[tag1] = key; cin >> val; cin.ignore(10,'"'); cin >> key; } string tag1 = tagStr; tag1.append("~"); tag1.append(val); key.erase(key.length()-2,key.npos); mp[tag1] = key; } else { stack.pop_back(); } } for (int i = 0 ; i < q; i++){ string tag1; cin >> tag1; if (mp.find(tag1) != mp.end()) { cout << mp[tag1] << '\n'; } else { cout << "Not Found!\n"; } } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Attribute Parser
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
include
include
include
using namespace std;
int main() { int n , q ; map mp; std::deque stack; cin >> n >> q;
}