• priority_queue custom compare(cmp)


    #include <bits/stdc++.h>
    //#define endl '
    '
    #define lose {printf("NO
    ");return;}
    #define win {printf("YES
    ");return;}
    #define all(A) (A).begin(),(A).end()
    #define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
    #define PER(I, A, B) for (int I = (A); I >= (B); --I)
    #define DB(A) cout<<(A)<<endl 
    #define lson k*2
    #define rson k*2+1
    #define fi first
    #define se second
    #define PB push_back
    #define Pair pair<int,int>
    #define MP make_pair
    #define LL long long
    #define ull unsigned long long
    //#define int LL
    using namespace std;
    #define DB1(args...) do { cout << #args << " : "; dbg(args); } while (0)
    void dbg() { std::cout << "  #
    "; }
    template<typename T, typename...Args>
    void dbg(T a, Args...args) { std::cout << a << ' '; dbg(args...); }
    //var
    const int maxn=2e5+10;
    const int MAX=1000;
    const int inf=0x3f3f3f3f;   
    const int mod=1e9+7;
    //head
    int n,m;
    int w[maxn]; 
    int d[maxn];
    int last[maxn];
    
    
    
    
    void solve()
    {
    
    	last[1]=1;
    	last[2]=2;
    	auto cmp = [](int a, int b) { return last[a] > last[b]; };//who bigger who first
    	priority_queue<int,vector<int>, decltype(cmp)> q(cmp);
    	q.push(1);
    	q.push(2);
    	DB1(q.top());
    	q.pop();
    	DB1(q.top());
    	q.pop();
    	//but it turns out that they left the big number behind( greater )
     
    	
    	
    
    	
    } 
    signed main()
    {
        // freopen("read.txt", "r", stdin);
        // freopen("ans.txt", "w", stdout);
        int TestCase = 1;
        //cin>>TestCase;
        while (TestCase--)
        {
            solve();
        }
        char EndFile = getchar();
        EndFile = getchar();
        return 0;
    }
    
    
  • 相关阅读:
    数据结构与算法——优先队列类的C++实现(二叉堆)
    Effective C++--经验条款
    [精]读览天下免费阅读平台
    团队现状与用人标准——揭秘万达电商(6)
    稀疏向量计算优化小结
    漫谈雪崩
    Git起步
    Solr 配置文件之schema.xml
    Shader toy (顺手写两个Gyro)(纯代码写3D)
    Tomcat服务器安装
  • 原文地址:https://www.cnblogs.com/reshuffle/p/13860808.html
Copyright © 2020-2023  润新知