首页 > 其他分享 >HDOJ 5252 追星族

HDOJ 5252 追星族

时间:2023-07-05 20:33:09浏览次数:33  
标签:5252 int res LL define base 追星族 include HDOJ


对于n个点,先按时间排序。二分答案,对于二分的当前值dis,我们将每个点向外扩展dis个距离,也就是个正方形。这个点和前一个时间点差的时间d也作为前一个距离,向外扩展d。。。。求交以后存在矩形,那么二分当前值存在,否则不存在。。。。


#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <time.h>
#define maxn 50005
#define maxm 100005
#define eps 1e-12
#define mod 1000003
#define INF 0x3f3f3f3f
#define PI (acos(-1.0))
#define lowbit(x) (x&(-x))
#define mp make_pair
#define ls o<<1
#define rs o<<1 | 1
#define lson o<<1, L, mid 
#define rson o<<1 | 1, mid+1, R
#pragma comment(linker, "/STACK:102400000,102400000")
#define pii pair<int, int> 
typedef long long LL;
typedef unsigned long long ULL;
//typedef int LL;
using namespace std;
LL qpow(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base;base=base*base;b/=2;}return res;}
LL powmod(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base%mod;base=base*base%mod;b/=2;}return res;}
// head

struct node
{
	LL x, y, t;
}a[maxn];
int n;

int cmp(node aa, node bb)
{
	return aa.t < bb.t;
}

bool check(LL dis)
{
	LL x1 = -10000000000LL;
	LL y1 = -10000000000LL;
	LL x2 = 10000000000LL;
	LL y2 = 10000000000LL;
	for(int i = 1; i <= n; i++) {
		LL t = 0;
		if(i != 1) t = a[i].t - a[i-1].t;
		t *= 2;
		x1 -= t;
		y1 -= t;
		x2 += t;
		y2 += t;
		LL t1 = 2 * (a[i].y - a[i].x);
		LL t2 = 2 * (a[i].y + a[i].x);
		x1 = max(x1, t1 - dis);
		y1 = max(y1, t2 - dis);
		x2 = min(x2, t1 + dis);
		y2 = min(y2, t2 + dis);
		if(x1 > x2 || y1 > y2) return false;
	}
	return true;
}

void work()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].t);
	sort(a+1, a+n+1, cmp);	
	LL top = 40000000000LL, bot = 0, mid, res;
	while(top >= bot) {
		mid = bot + (top - bot) / 2;
		if(check(mid)) res = mid, top = mid-1;
		else bot = mid+1;
	}
	if(res % 2) printf("%lld/2\n", res);
	else printf("%lld/1\n", res / 2);
}

int main()
{
	int _;
	scanf("%d", &_);
	for(int i = 1; i <= _; i++) {
		printf("Case #%d:\n", i);
		work();
	}
	
	return 0;
}




标签:5252,int,res,LL,define,base,追星族,include,HDOJ
From: https://blog.51cto.com/u_8692734/6634971

相关文章

  • 【高斯消元】 HDOJ 5257 翻转游戏
    如果第一行的状态确定了,那么矩阵的所有状态也会随之确定。。。那么我们就将第一行写成变量,这样能够推出矩阵的m个方程。。。然后对于k,可以写出k个限制方程。。因此我们总共列出m+k个方程,高斯消元,bitset优化即可。。。#include<iostream>#include<queue>#include<stack>#inclu......
  • 【并查集】 HDOJ 4786 Fibonacci Tree
    就是求出搞成最小生成树的最少白边和最多白边的数量。。。。#include<iostream>#include<queue>#include<stack>#include<map>#include<set>#include<bitset>#include<cstdio>#include<algorithm>#include<cstring>#include<......
  • HDOJ 5296 Annoying problem
    根据每次的加点删点求对答案的贡献。。。#include<iostream>#include<queue>#include<stack>#include<map>#include<set>#include<bitset>#include<cstdio>#include<algorithm>#include<cstring>#include<climits&g......
  • 【树分治】HDOJ 5016
    先预处理出每个点的最近点。。。。然后考虑固定根,对于每个根,从根到子树的路径中任选两条,如果dis[i]+dis[j]<w[j]。那么i就是j的一个合法点。。。。然后递归处理子树即可。。。。扩栈才过的。。。#include<iostream>#include<queue>#include<stack>#include<map>#includ......
  • hdoj-5903 Square Distance
    原题链接SquareDistanceTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):245    AcceptedSubmission(s):83ProblemDescriptionAstringiscalledasquarestringifitcanbeobtainedbyconcatena......
  • hdoj 展开字符串 1274 (字符串递归) 好题
    展开字符串TimeLimit:2000/1000MS(Java/Others)   MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):2116   AcceptedSubmission(s):1017ProblemDescription在纺织CAD系统开发过程中,经常会遇到纱线排列的问题。该问题的描述是这样的......
  • hdoj 前m大的数 1280 (技巧&暴力)
    前m大的数TimeLimit:2000/1000MS(Java/Others)   MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):14345   AcceptedSubmission(s):4888ProblemDescription还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的......
  • Integer Inquiry hdoj 1047
    IntegerInquiryTimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):15216    AcceptedSubmission(s):3909ProblemDescriptionOneofthefirstusersofBIT'snewsupercomputerwasChipDill......
  • hdoj Lining Up 1432 (数学)直线过最多点问题
    LiningUpTimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):1251    AcceptedSubmission(s):356ProblemDescription``HowamIevergoingtosolvethisproblem?"sa......
  • hdoj 夹角有多大(题目已修改,注意读题) 2076 (数学&转换)
    夹角有多大(题目已修改,注意读题)TimeLimit:1000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):13233    AcceptedSubmission(s):5214ProblemDescription时间过的好快,一个学期就这......