随笔 - 531  文章 - 0  评论 - 3  阅读 - 10215 

n头牛站成一行,每头牛的身高都为整数。

当且仅当两头牛中间的牛身高都比它们矮时,两头牛方可看到对方。

我们只知道其中最高的牛是第 pos 头,它的身高是H , 剩余牛的身高未知。

知道这群牛之中存在着 t 对关系,每对关系都指明了某两头牛B

可以相互看见。

求每头牛的身高的最大可能值是多少。

 

复制代码
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 const int N=1e5+4;
 #define int long long
 map<int,int> mp[N];
 int n,pos,H,a[N],df[N];
 void sov(){
     int i,l,r,tes;
      cin>>n>>pos>>H>>tes;
      
     while(tes--){
         cin>>l>>r;
         if(l>r) swap(l,r); 
         if(mp[l][r]==0) mp[l][r]=1,df[l+1]--,df[r]++;
     }
     for(i=1;i<=n;i++){
         df[i]+=df[i-1]; cout<<df[i]+H<<endl;
     }
 }
  main(){
     sov();
 }
复制代码

 

posted on   towboat  阅读(15)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示