814-The Letter Carrier's Rounds【模拟、STL、被坑了】
来源:互联网 发布:js如何给input赋值 编辑:程序博客网 时间:2024/04/30 10:07
一道比较水的STL的练习题,被坑的老妈都认不出来了
被坑的地方是 在一次输入中 你如果给同一个人多次发邮件,那么只输出一次结果,我了个擦,被坑死了。。还是英语烂,直接跪了
跑的比较慢,没做优化
#include<map>#include<vector>#include<queue>#include<stack>#include<cstdio>#include<string>#include<cstring>#include<set>#include<algorithm>#include<iostream>using namespace std;const int maxn = 11111;const int maxd = 5555;map<string,int>name; //运营商映射vector<string>ID[maxn];int cnt = 1;void GetMAT(){ char str[maxd],str2[maxd]; while(cin >> str){ if(str[0] == '*') break; int m; cin >> str >> m; name[string(str)] = cnt; for(int i = 0; i < m; i++){ cin >> str2; ID[cnt].push_back(str2); } cnt ++; } return;}bool GetAddress(char str[3][maxd]){ int L,now = 1,pos = 0; cin >> str[0]; if(str[0][0] == '*') return false; L = strlen(str[0]); for(int i = 0; i <= L; i ++){ if(str[0][i] == '@' || str[0][i] == '\0'){ str[now][pos] = '\0'; now ++; pos = 0; } else str[now][pos++] = str[0][i]; } return true;}char str2[maxd][3][maxd];char data[maxd][maxd];set<string>have_send;bool SendEmail(){ have_send.clear(); char str[3][maxd]; int vis[maxd] = {0}; if(!GetAddress(str)) return false; int ret = 0,ret2 = 0; string sender(str[1]); string matt(str[2]); while(GetAddress(str2[ret])) ret++; getchar(); while(gets(data[ret2])){ if(data[ret2][0] == '*') break; ret2++; } for(int i = 0; i < ret; i++){ string user(str2[i][1]); string mat(str2[i][2]); int fr = name[mat]; //找出运营商 if(!vis[fr]){ vis[fr] = 1; cout << "Connection between " << matt << " and " << mat << endl; cout << " HELO " << matt << endl; cout << " 250" << endl; cout << " MAIL FROM:" << "<" << sender << "@" << matt << ">" << endl; cout << " 250" << endl; int ok = 0; //发消息 for(int j = i; j < ret; j++){ string us(str2[j][1]); string ma(str2[j][2]); int f = name[ma]; if(f == fr && !have_send.count(string(us + "@" + ma))){ have_send.insert(string(us + "@" + ma)); cout << " RCPT TO:<" << us << "@" << ma << ">" << endl; int have_find = 0; for(int k = 0; k < ID[f].size(); k++){ if(ID[f][k] == us){ ok = 1; have_find = 1; cout << " 250" << endl; break; } } if(!have_find) cout << " 550" << endl; } } if(ok){ cout << " DATA" << endl; cout << " 354" << endl; for(int z = 0;z < ret2 ; z++) cout << " " << data[z] << endl; cout << " ." << endl; cout << " 250" << endl; } cout << " QUIT" << endl; cout << " 221" << endl; } } return true;}int main(){ GetMAT(); while(SendEmail()); return 0;}
0 0
- 814-The Letter Carrier's Rounds【模拟、STL、被坑了】
- UVa 814 - The Letter Carrier's Rounds(模拟)
- 814 - The Letter Carrier's Rounds
- 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)
- UVa814 - The Letter Carrier's Rounds
- uva814-The letter Carrier's Rounds
- The Letter Carrier's Rounds UVA
- UVa 814 The Lettter Carrier's Rounds
- 例题5-11 UVA 814 The Letter Carrier’s Rounds邮件传输代理的交互
- VUA814-The Letter Carrier's Rounds(入门经典5-11,PE)
- How To get the usbdisk's drive letter properly
- Lesson Forty-Five The boss's letter. 老板的信.
- Lesson 45 The boss's letter 老板的信
- HDU-5437 Alisha’s Party(STL+模拟)
- UML关系图
- ibatis/mybatis
- Longest Substring Without Repeating Characters
- online_judge_1074
- QSslSocket: cannot resolve SSLv2_client_method
- 814-The Letter Carrier's Rounds【模拟、STL、被坑了】
- 宇宙本源论
- 理解“统一编址,独立编址,IO端口IO内存”
- 如何将.java文件编译成.class文件
- Codeforces Beta Round #75 (Div. 1 Only)---B.Queue
- 数据库第二次作业
- CentOS中由一般用户切换为root用户
- 蓝桥杯: 蚂蚁感冒
- Android API 中文 — ListView