Reverse proxies

This post was flagged by the community and is temporarily hidden.

It was weird.

Also wanted help.

1 Like

Can you tell the complete problem?

1 Like

#include<bits/stdc++.h>
using namespace std;
//read domain
string read(string s){
int i=0;
string domain="";
while(s[i]!=’/’){
domain+=s[i];
i++;
}
return domain;
}

//readup
string read_up(string s){
int i=0;
string ip="";
string up="";
while(s[i]!=’/’){
i++;
}
i++;
while(i<s.length() && s[i]!=’/’ && s[i]!=’?’)
{
up+=s[i];
i++;
}
i++;
if(up==“machine_up”){
i+=3;
while(i<s.length())
{
ip+=s[i];
i++;
}
}
return ip;
}

//readdown
string read_down(string s){
int i=0;
string ip="";
string down="";
while(s[i]!=’/’){
i++;
}
i++;
while(i<s.length()&&s[i]!=’/’ && s[i]!=’?’)
{
down+=s[i];
i++;
}
i++;
if(down==“machine_down”){
i+=3;
while(i<s.length())
{
ip+=s[i];
i++;
}
}
return ip;
}
int main(){
#ifndef ONLINE_JUDGE
freopen(“input.txt”,“r”, stdin);
freopen(“output.txt”,“w”,stdout);
#endif

int n,urlcnt,count,queries;
string url_s,s,p;
map<string,vector<string>>mp;
map<string,queue<string>>mp1;
cin>>n;
for(int i=0;i<n;i++){
cin>>p;
}

cin>>urlcnt;
for(int i=0;i<urlcnt;i++){
 cin>>url_s;
 cin>>count;
 queue<string>q;
 for(int j=0;j<count;j++){
  cin>>s;
  q.push(s);
 }
 mp1[url_s]=q;
}

cin>>queries;
for(int i=0;i<queries;i++){
cin>>s;
//cout<<“query***”<<endl;
//cout<<s<<endl;
string domain=read(s);
string up=read_up(s);
string down=read_down(s);
if(up==""&& down==""){
// cout<<“fine”<<endl;
queueq=mp1[domain];

  string machine=q.front();
  q.pop();
  //cout<<machine<<" "<<s<<endl;
  mp[machine].push_back(s);
  q.push(machine);
  mp1[domain]=q;

}
else if(up!=""){
queueq=mp1[domain];
q.push(up);
string temp=q.front();
q.pop();
q.push(temp);
mp1[domain]=q;
}
else if(down!=""){
queuemodified;
queueq=mp1[domain];
//cout<<“down”<<down<<endl;
while(!q.empty() && q.front()!=down){
//cout<<q.front()<<endl;
modified.push(q.front());
q.pop();
}
q.pop();
while(!q.empty()){
//cout<<q.front()<<endl;
modified.push(q.front());
q.pop();
}
mp1[domain]=modified;
}

}

for(auto it:mp){
cout<<it.first<<endl;
vectorvec=it.second;
for(auto it1:vec)
cout<<it1<<endl;
}

return 0;
}

I don’t understand the problem and solution.
Someone please help !!
@bidibaaz123 Can you help

This post was flagged by the community and is temporarily hidden.

executeQuery method needs some rework…

This post was flagged by the community and is temporarily hidden.

This post was flagged by the community and is temporarily hidden.