跳到正文

题解

题解:CF1733E Conveyor

XxLlQq约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年7月12日
收录
2025年12月12日
更新
2026年10月27日
篇幅
约 2 分钟
题目
CF1733E

版本

  1. v1当前

思路

首先我们发现 xx , yy 的数据范围都很小但同时询问次数 tt 的范围又很大。所以我们不能一次次直接模拟。

我们会发现如果在 tt 秒时 f[x][y]f[x][y] 处有史莱姆,那么这个史莱姆在 t−x−yt-x-y 秒时肯定是在原点的。那么我们就将这全部的史莱姆 tt 个看作一个整体,模拟每个格子中会经过多少的史莱姆。那么只要我们求的 f[x][y]f[x][y] 在 tt 和 t−1t-1 秒经过的个数不同,那么在 tt 秒便一定会有史莱姆经过。

所以记 a[i][j]a[i][j] 为 tt 秒经过 (i,j)(i,j) 的数量。则有:

a[i][j]=a[i−1][j]/2+(a[i][j−1]+1)/2a[i][j]=a[i-1][j]/2+(a[i][j-1]+1)/2

code

C++
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#define ll long long 
using namespace std;
const ll N=125;
ll n,m,t,k,a[N][N],b[N][N];
int main() {
	cin>>t;
	while(t--) {
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		cin>>k>>n>>m;
		a[1][1]=k-n-m+1;
		b[1][1]=k-n-m;
		for(ll i=1; i<=n+1; i++) {
			for(ll j=1; j<=m+1; j++) {
				a[i][j]+=a[i-1][j]/2;
				a[i][j]+=(a[i][j-1]+1)/2;
				b[i][j]+=b[i-1][j]/2;
				b[i][j]+=(b[i][j-1]+1)/2;
			}
		}
		if(a[n+1][m+1]>b[n+1][m+1]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}
原文