Attribute Parser

Sort by

recency

|

500 Discussions

|

  • + 0 comments

    Nice problem, but more details are needed on the valid characters that make up the tag, attribute and value sequences

  • + 0 comments

    include

    include

    include

    include

    include

    include

    using namespace std;

    int main() { int count, query; cin>>count>>query; cin.ignore(); stack st; unordered_map mp; while(count--){ string line; getline(cin,line); if(line[1] == '/'){ st.pop(); continue; } line=line.substr(1,line.size()-2); stringstream ss(line);

        string tag;
        ss>>tag;
    
        string path =tag;
        if(!st.empty()) path = st.top() + "." + tag;
        st.push(path);
    
          string attr, eq, val;
        while(ss >> attr) {
            ss >> eq >> val;
            val = val.substr(1, val.size()-2);
            mp[path + "~" + attr] = val;
      }
      }
      while(query--) {
        string query;
        getline(cin, query);
    
        if(mp.count(query))
            cout << mp[query] << endl;
        else
            cout << "Not Found!" << endl;
    }
    

    }

  • + 0 comments

    it’s a valuable problem for building strong fundamentals in C++ and competitive programming. Telugu365 in

  • + 0 comments

    Well done. The parser design is clear, maintainable, and well-suited for preparing C++ string attributes accurately Radheexch xyz login

  • + 0 comments

    It pushes you to think carefully about input formats and edge cases rather than just syntax. Radheexch xyz