哒哒哒哒 一些有趣的东西 HihoCoder 1082 &&CUGOJ 1569

来源:互联网 发布:nginx生成ssl证书 编辑:程序博客网 时间:2024/05/01 17:31

沼泽鱼已经看穿了一切hhhhh

STL大法好


下面是一个优先级队列使用的例子,反正自己看的,随便

#include<iostream>#include<vector>#include<algorithm>#include<cmath>#include<string>#include<list>#include<stdlib.h>using namespace std;int main() {string s;while (getline(cin,s)) {string temp=s;for (int i = 0; i < s.size(); i++) {if (s[i] >= 'A'&&s[i] <= 'Z')s[i] += 32;}int flag = s.find("marshtomp");while (flag != s.npos) {s.erase(flag, 9);s.insert(flag, "fjxmlhx");temp.erase(flag, 9);temp.insert(flag, "fjxmlhx");flag = s.find("marshtomp");}cout << temp << endl;}return 0;}

#include<iostream>#include<algorithm>#include<string>#include<queue>#include<cmath>#include<vector>#include<stdlib.h>#include<iomanip>#include<map>#include<stack>#include<memory.h>using namespace std;typedef long long ll;struct paticent{int id;int doctor;int ill;};struct cmp {bool operator ()(paticent &a, paticent &b) {if (a.ill != b.ill) {return a.ill < b.ill;}else return a.id > b.id;}};int main() {priority_queue<paticent, vector<paticent>, cmp> que1;priority_queue<paticent, vector<paticent>, cmp> que2;priority_queue<paticent, vector<paticent>, cmp> que3;paticent pe;string s; int a, b;int t;while (scanf("%d", &t) != -1) {while (!que1.empty()) { que1.pop(); }while (!que2.empty()) { que2.pop(); }while (!que3.empty()) { que3.pop(); }int flag(0);for (int i = 0; i < t; i++) {cin >> s;if (s == "IN") {cin >> a >> b;flag++;pe.id = flag;pe.doctor = a;pe.ill = b;if (a == 1)que1.push(pe);else if (a == 2)que2.push(pe);else que3.push(pe);}if (s == "OUT") {cin >> a;if (a == 1) {if (!que1.empty()) {cout << que1.top().id << endl;que1.pop();}else cout << "EMPTY" << endl;}else if (a == 2) {if (!que2.empty()) {cout << que2.top().id << endl;que2.pop();}else cout << "EMPTY" << endl;}else if (a == 3) {if (!que3.empty()) {cout << que3.top().id << endl;que3.pop();}else cout << "EMPTY" << endl;}}}}return 0; }





原创粉丝点击