UVa 814 - The Letter Carrier's Rounds(模拟)
来源:互联网 发布:2017网络流行骂人热词 编辑:程序博客网 时间:2024/05/17 05:05
模拟邮件的发送,把每一个地址保存下来, 然后在搜索能否找到匹配的地址。
#include <iostream>#include <cstdio>#include <string>#include <set>#include <map>#include <vector>using namespace std;void parse_address(string const s, string& user, string& mta) { int t = s.find('@'); user = s.substr(0, t); mta = s.substr(t + 1);}int main() {#ifndef ONLINE_JUDGE freopen("test", "r", stdin);#endif // ONLINE_JUDGE int k; string s, t, user1, user2, mta1, mta2; set<string> addr; while(cin >> s&& s[0] != '*') { cin >> t >> k; while(k--) {cin >> s; addr.insert(s + '@' + t);} } while(cin >> s&& s[0] != '*') { parse_address(s, user1, mta1); vector<string> mta; map<string, vector<string> > dest; set<string> vis; while(cin >> t&& t[0] != '*') { if(vis.count(t)) continue; vis.insert(t); parse_address(t, user2, mta2); if(!dest.count(mta2)) {mta.push_back(mta2); dest[mta2] = vector<string>();} dest[mta2].push_back(t); } getline(cin, t); string data; while(getline(cin, t)&& t[0] != '*') data += " " + t + "\n"; for(int i = 0; i < mta.size(); i++) { mta2 = mta[i]; vector<string> users = dest[mta2]; cout << "Connection between " << mta1 << " and " << mta2 << "\n"; cout << " HELO "<< mta1 << "\n"; cout << " 250\n"; cout << " MAIL FROM:<" << user1 << "@" << mta1 << ">\n"; cout << " 250\n"; bool ok = false; for(int i = 0; i < users.size(); i++) { cout << " RCPT TO:<" << users[i] << ">\n"; if(addr.count(users[i])) {ok = true; cout << " 250\n"; } else cout << " 550\n"; } if(ok) { cout << " DATA\n 354\n"; cout << data; cout << " .\n" << " 250\n"; } cout << " QUIT\n 221\n"; } } return 0;}
0 0
- UVa 814 - The Letter Carrier's Rounds(模拟)
- uva 814 The Letter Carrier's Rounds
- The letter Carrier's Rounds(Uva 814)
- 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
- UVa 814 The Lettter Carrier's Rounds
- 例题5-11 UVA 814 The Letter Carrier’s Rounds邮件传输代理的交互
- 814-The Letter Carrier's Rounds【模拟、STL、被坑了】
- UVa814 - The Letter Carrier's Rounds
- uva814-The letter Carrier's Rounds
- VUA814-The Letter Carrier's Rounds(入门经典5-11,PE)
- UVA Where's Waldorf?(模拟)
- uva 10881 Piotr's Ants (模拟)
- UVa 10196 - Check The Check (模拟)
- UVA 101 - The Blocks Problem(模拟)
- Oracle 字符串分割 Split
- PAT 1095. Cars on Campus
- 第二周项目四图书馆的书
- Oracle 单引号 双重角色
- 上喵吧,最强免费等你来约
- UVa 814 - The Letter Carrier's Rounds(模拟)
- 第三周——基于对象的程序设计——工资类(1)手动输入
- MongoDB常用操作命令大全
- MySQL与Oracle的语法区别详细对比
- Oracle Database Link
- UIScrollView简单使用
- CGLIB 测试
- windows下mongodb安装与使用整理
- 常用数据库的树形查询