We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;#include<sstream>#include<map>#include<queue>intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */priority_queue<string>keys;map<string,map<string,string>>data;intdataCount;intqueryCount;// read the number of data and querystringline;getline(cin,line);istringstreamiss(line);iss>>dataCount>>queryCount;for(inti=0;i<dataCount;i++){getline(cin,line);line.pop_back();istringstreamiss(line);stringtoken;stringkey="";stringvalue="";stringoperation="";iss>>token;if(token[1]=='/'){keys.pop();continue;}if(token[0]=='<'){if(keys.empty()){keys.push(token.substr(1));}else{keys.push(keys.top()+'.'+token.substr(1));}}while(iss>>token){if(key==""){key=token;continue;}if(operation==""){operation=token;continue;}if(value==""){value=token;data[keys.top()][key]=value.substr(1,value.length()-2);key="";operation="";value="";continue;}}}for(inti=0;i<queryCount;i++){getline(cin,line);size_tdelimiterPos=line.find('~');if(data[line.substr(0,delimiterPos)][line.substr(delimiterPos+1)].empty()){cout<<"Not Found!"<<endl;}else{cout<<data[line.substr(0,delimiterPos)][line.substr(delimiterPos+1)]<<endl;}}return0;}
Cookie support is required to access HackerRank
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 →