您当前的位置: 首页 > 

先求一个导

暂无认证

  • 2浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

程序设计天梯赛L3-5 (数组开小然后T了,样例不过的代码才能AC,逆天盲僧)

先求一个导 发布时间:2022-02-23 16:51:17 ,浏览量:2

题目 题意: 给定n个点,k个垃圾箱,m条边。(n=1e3,k=10,m=1e4)现在要从k个垃圾箱中选择一个合适的垃圾箱。合适的垃圾箱要满足到n个点的最短距离最大。如果有多个,则选到n个点的平均距离最小的。如果仍有多个,则选编号最小的。 思路: k才10,挨个跑一遍Dij就够用。这个题也挺逆天,样例是3.3,结果应该是3.25,如果四舍五入成3.3,过了样例但是会WA。如果输出3.2,过不了样例但是AC。什么逆天盲僧 时间复杂度: O(k * mlogm) 代码:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i>limit;
   for(int i=0;i>a>>b>>z;
   	  if(a[0] == 'G') {a = a.substr(1); x = stoi(a)+n;}
   	  if(b[0] == 'G') {b = b.substr(1); y = stoi(b)+n;}
   	  if(x==0) x = stoi(a);
   	  if(y==0) y = stoi(b);
   	  add(x,y,z); add(y,x,z);
   }
   int idx = n; int cnt = 0;
   for(int t=n+1;cnt             
关注
打赏
1662037414
查看更多评论
0.0372s