zoukankan      html  css  js  c++  java
  • hdu 1908数据结构水题

    平衡二叉树就可以,我是用的set。

    /*
     * hdu1908/win.cpp
     * Created on: 2012-11-2
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        int op, a, b;
        set<pair<int, int> > S;
        while(scanf("%d", &op) == 1 && op > 0) {
            if(op == 1) {
                scanf("%d%d", &a, &b);
                S.insert(make_pair(b, a));
            }else if(S.empty()) {
                puts("0");
            }else if(op == 3) {
                printf("%d\n", (*S.begin()).second);
                S.erase(S.begin());
            }else {
                set<pair<int, int> >::iterator it = S.end();
                it--;
                printf("%d\n", (*it).second);
                S.erase(it);
            }
        }
        return 0;
    }
  • 相关阅读:
    Python解释器相关知识
    简单了解下Flask
    Scoket编程
    __file__的作用
    jquery编写可折叠列表
    浑浑噩噩的一天
    js实现杨辉三角
    js闭包
    python读取word表格
    HTMLTestRunner报告
  • 原文地址:https://www.cnblogs.com/moonbay/p/2750907.html
Copyright © 2011-2022 走看看