2018-03-10 STL

优先队列
结构体优先队列

// 这里是小的优先,默认是大的优先
#include
using namespace std;
typedef long long ll;
ll t,n;
priority_queue,greater >q;
int  main(){

q.push(3);
q.push(2);
int x=q.top();
cout<
#include
using namespace std;
struct node
{
    int x,y;
    bool operator < (const node & a) const
    {
        return x q;
int main()
{
    k.x=10,k.y=100; q.push(k);
    k.x=12,k.y=60; q.push(k);
    k.x=14,k.y=40; q.push(k);
    k.x=6,k.y=80; q.push(k);
    k.x=8,k.y=20; q.push(k);
    while(!q.empty())
    {
        node m=q.top(); q.pop();
        printf("(%d,%d) ",m.x,m.y);
    }
}

set

// [天梯](https://www.patest.cn/contests/gplt/L2-014)
#include
using namespace std;
typedef long long ll;

int  main(){
int n;
sets;
cin>>n;
int t;
s.insert(0);
for(int i=0;i>t;
    if(*s.rbegin()>t){
        s.erase(s.upper_bound(t));
    }
    s.insert(t);
}
cout<

map

//  定义的三元组 用 map 判读是否 重复出现
#include
using namespace std;
typedef long long ll;
#define N 25004
int k;
ll aa[N];

int c=0;


ll  gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}

    class Key
    {
    public:
        Key();
        Key(ll a,ll b,ll c);
        ll x,y,z;
        ~Key();

        bool operator <(const Key& key) const;
    };
    bool Key::operator <(const Key &key)  const
    {        if(this->xx==key.x&&this->yx==key.x&&this->y==key.y&&this->zma;
int main()
{
    cin>>k;
    ll x,y,z;
    cin>>x>>y>>z;
    ll a,c,b;

       for(int i=1;i>a>>b>>c;
          a=a-x;
          b-=y;c-=z;
          if(a!=0&&b!=0&&c!=0)
          {
         ll tem=gcd(a,b);
         tem=gcd(tem,c);
         a/=tem;b/=tem;c/=tem;
          }
         Key node;
         node.x=a;node.y=b;node.z=c;
       //  cout<<"dsaf "<

你可能感兴趣的:(2018-03-10 STL)