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;
    }
  • 相关阅读:
    element-ui 刷新页面不能自动打开对应的菜单
    cookie
    cdn
    为已有文件添加 d.ts 声明
    WiFi 漫游过程
    Wifi 4 way handshake 四次握手
    WiFi association request/response
    WiFi beacon
    WiFi Auth/Deauth帧
    WiFi probe request/response
  • 原文地址:https://www.cnblogs.com/moonbay/p/2750907.html
Copyright © 2011-2022 走看看