Coede
Coede
Coede
#include<bits/stdc++.h>
using namespace std;
struct Node{
string val;
Node* parent;
vector<Node*> children;
bool isLocked;
int lcc;
int locked_by_id;
unordered_map<Node*,int> children_locked;
return true;
}
return true;
}
else
{
return false;
}
root->isLocked = false;
root->locked_by_id = -1;
return true;
int main()
{
// int n,m,q;
// cin>>n>>m>>q;
// vector<string> arr;
// vector<string> queries;
// for(int i=0; i<n; i++)
// {
// string s;
// cin>>s;
// arr.push_back(s);
// }
// for(int i=0; i<q; i++)
// {
// string qu;
// cin>>qu;
// queries.push_back(qu);
// }
/////////////////////////////////////////////////////////////////////// TREE
AND MAP CREATION
unordered_map<string,Node*> m1;
int i = 0;
int j = 1;
while(j<n)
{
for(int k = 0; k<m; k++)
{
if(j<n)
{
Node* child = new Node(arr[j], m1[arr[i]]);
m1[arr[j]] = child;
m1[arr[i]]->children.push_back(child);
j++;
}
else
{
break;
}
}
i++;
}
///////////////////////////////////////////////////////// PRINTING
cout<<"\nDETAILS----------------------------------\n";
unordered_map<string,Node*>::iterator itr;
for(itr=m1.begin(); itr!=m1.end(); itr++)
{
cout<<itr->first<<"---\n";
cout<<"isLocked: "<<itr->second->isLocked<<",LCC: "<<itr->second->lcc<<",
locked_by_id: "<<itr->second->locked_by_id;
unordered_map<Node*,int>::iterator itr2;
cout<<", Children Locked[";
for(itr2=itr->second->children_locked.begin(); itr2!=itr->second-
>children_locked.end(); itr2++)
{
cout<<itr2->first->val<<"-"<<itr2->second<<", ";
}
cout<<"]";
// for(int k=0; k<itr->second->children.size(); k++)
// {
// cout<<itr->second->children[k]<<",";
// }
cout<<"\n";
}