搜索
您的当前位置:首页正文

c++实现最高的牛

来源:吉趣旅游网

使用multimap

#include<bits/stdc++.h>
using namespace std;
#define ll long long
multimap <ll,ll> mp;
ll a[10010];
int main()
{
    ll N,P,H,M,A,B;
    cin>>N>>P>>H>>M;
    for(int i=1;i<=N;i++){
        a[i] = H;
    }
    for(int i=0;i<M;i++){
        bool x = true;
        cin>>A>>B;
        if(A>B){
            swap(A,B);
        }
    for (auto itr = mp.find(A); itr != mp.end(); itr++){
        if(itr->first != A){
            break;
        }else{
            if(itr->second==B){
                x = false;
                break;
            }
        }
    }
    if(x){
       mp.insert(make_pair(A,B));
        for(int j=A+1;j<B;j++){
            a[j] = a[j]-1;
        }
    }
    }
    for(int i=1;i<=N;i++){
        cout<<a[i]<<endl;
    }


    return 0;
}

因篇幅问题不能全部显示,请点此查看更多更全内容

Top