UVa 814 The Lettter Carrier's Rounds
来源:互联网 发布:淘宝客服聊天话术技巧 编辑:程序博客网 时间:2024/05/18 03:46
#include<iostream>#include<cstdio>#include<string>#include<map>#include<sstream>#include<algorithm>#include<vector>#include<queue>#include<set>#include<cstring>#include<stack>#include<iomanip>using namespace std;int main(){map<string,set<string> > str2set;map<string,int> str2int;string s; getline(cin,s);int amount=0;while(s[0]!='*'){int t=s.find(' ',4);string name=s.substr(4,t-4);str2int[name]=amount;t++;int t2=s.find(' ',t);while(t2!=-1){string temp=s.substr(t,t2-t);if(str2set.count(name)==0){set<string> a;str2set[name]=a;}str2set[name].insert(temp);t=t2+1;t2=s.find(' ',t);} string temp=s.substr(t); str2set[name].insert(temp);s="";getline(cin,s);amount++;}string st;cin>>st;int i;while(1){queue<pair<string,string> > *q=new queue<pair<string,string> >[amount];if(st[0]=='*') break;string sender;sender=st;vector<string> rcpt;cin>>st;while(st[0]!='*'){rcpt.push_back(st);cin>>st;}vector<string> content;string t11;getline(cin,t11);//消除多余的换行st="";getline(cin,st);while(st[0]!='*'){content.push_back(st);st="";getline(cin,st);}queue<int> q2;set<int> Set;set<pair<string,string> > Set2;for(i=0;i<rcpt.size();i++){pair<string,string> temp;int t=rcpt[i].find('@',0);temp.first=rcpt[i].substr(0,t);temp.second=rcpt[i].substr(t+1);int t2=str2int[temp.second];if(Set.count(t2)==0){Set.insert(t2);q2.push(t2);}if(Set2.count(temp)==0){ q[t2].push(temp);Set2.insert(temp);}}int index1=sender.find('@',0);string start=sender.substr(index1+1);while(!q2.empty()){ pair<string,string> temp1; int index=q2.front();q2.pop();if(!q[index].empty()){cout<<"Connection between "<<start<<" and "<<q[index].front().second<<endl;cout<<" "<<"HELO "<<start<<endl;cout<<" "<<"250"<<endl;cout<<" "<<"MAIL FROM:<"<<sender<<">"<<endl;cout<<" "<<"250"<<endl;}int flag=0;while(!q[index].empty()){temp1=q[index].front();q[index].pop();cout<<" "<<"RCPT TO:<"<<temp1.first<<"@"<<temp1.second<<">"<<endl;if(str2set[temp1.second].count(temp1.first)){cout<<" "<<"250"<<endl;flag=1;}else{cout<<" "<<"550"<<endl;}}if(flag){ cout<<" "<<"DATA"<<endl<<" "<<"354"<<endl; for(i=0;i<content.size();i++) cout<<" "<<content[i]<<endl; cout<<" "<<"."<<endl<<" "<<"250"<<endl;}cout<<" "<<"QUIT"<<endl<<" "<<"221"<<endl;}cin>>st;}return 0;}
0 0
- UVa 814 The Lettter Carrier's Rounds
- uva 814 The Letter Carrier's Rounds
- The letter Carrier's Rounds(Uva 814)
- uva 814 The Letter Carrier's Rounds
- UVa 814 - The Letter Carrier's Rounds(模拟)
- The Letter Carrier's Rounds(UVa 814)
- The Letter Carrier's Rounds UVA
- 814 - The Letter Carrier's Rounds
- 814 - The Letter Carrier's Rounds
- 例题5-11 UVA 814 The Letter Carrier’s Rounds邮件传输代理的交互
- UVa814 - The Letter Carrier's Rounds
- uva814-The letter Carrier's Rounds
- 814-The Letter Carrier's Rounds【模拟、STL、被坑了】
- VUA814-The Letter Carrier's Rounds(入门经典5-11,PE)
- UVA The Sultan's Successors
- Carrier Ethernet: Providing the Need for Speed
- UVa 167 - The Sultan's Successors
- Uva 167 The Sultan's Successors
- loadView 和 viewDidLoad 区别
- JS prototype与__proto__的联系与区别
- Android 单例Toast优化
- 字符相关算法(二)
- C++11
- UVa 814 The Lettter Carrier's Rounds
- nodejs express框架 中app.js
- ASPxGridView 导出和部分属性设置
- Android Studio:Error:(1, 0) Your project path contains non-ASCII characters. This will most likely c
- Handler事件分发机制
- 自定义用作头像的选择器
- Java Swing简单控件实例(JButton,JLabel,JMenuBar,JComboBo)
- 爬虫入门-待续
- hdu 4193(单调队列)