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

沼泽鱼已经看穿了一切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;
 }





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值