| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用优先队列过的渣代码#include<iostream>
#include<queue>
using namespace std;
struct node {
int data;
bool type;
friend bool operator<(node a, node b)
{
if (a.data > b.data) return true;
else if (a.data == b.data) if (a.type < b.type) return true;
return false;
}
};
int main() {
ios::sync_with_stdio(false);
int num;
while (cin >> num) {
priority_queue<node, vector<node>> Q;
node stare = { 0,1 };
node end = {};
while (num --)
{
cin >> stare.data >> end.data;
Q.push(stare);
Q.push(end);
}
int count = 0;
int a;
while (!Q.empty()) {
node temp = Q.top();
Q.pop();
if (temp.type) {
if (count == 0) a = temp.data;
count++;
}
else {
count--;
if (count == 0) cout << a << " " << temp.data << endl;
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator