farm
farm
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
White Cloud wants to help White Rabbit fertilize plants, but the i-th plant can only adapt to the i-th fertilizer. If the j-th fertilizer is applied to the i-th plant (i!=j), the plant will immediately die.
Now White Cloud plans to apply fertilizers T times. In the i-th plan, White Cloud will use k[i]-th fertilizer to fertilize all the plants in a rectangle [x1[i]...x2[i]][y1[i]...y2[i]].
White rabbits wants to know how many plants would eventually die if they were to be fertilized according to the expected schedule of White Cloud.
输入描述:
The first line of input contains 3 integers n,m,T(n*m<=1000000,T<=1000000)
For the next n lines, each line contains m integers in range[1,n*m] denoting the type of plant in each grid.
For the next T lines, the i-th line contains 5 integers x1,y1,x2,y2,k(1<=x1<=x2<=n,1<=y1<=y2<=m,1<=k<=n*m)
输出描述:
Print an integer, denoting the number of plants which would die.
输入
2 2 2
1 2
2 3
1 1 2 2 2
2 1 2 1 1
输出
3
题意:n*m的矩阵里,每个格子都有一个数,有t次操作,每次都会选一个小矩形区域并且选择一个数x,这个小矩形区域里的数要是不等于x,这个数就会消失,问最后有多少个数会消失。
反过来想,这个数要是不消失,那么一旦这个数被选中,x肯定是等于这个数的。若把每一次的操作变成给矩形区域里都加上数x,那么最后若一个格子里的总和可以整除格子里的数,这个数则会有很大概率不消失。
于是考虑给矩阵里的数重新分配权值,且每次操作的x值也变为新的权值,这样就会很大概率避免错误情况。
#include<bits/stdc++.h>
#define N 1000100
using namespace std; vector<int>Map[N];
vector<long long>dis[N];
int Rand[N]; int main()
{
int n,m,t;
scanf("%d %d %d",&n,&m,&t); for(int i=;i<=n;i++)
{
Map[i].push_back();
dis[i].push_back();
for(int j=;j<=m;j++)
{
int a;
scanf("%d",&a);
Map[i].push_back(a);
dis[i].push_back();
}
}
srand(time());
for(int i=;i<=n*m;i++)Rand[i]=rand()*rand()%+rand(); while(t--)
{
int a,b,c,d,k;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&k); dis[a][b]+=Rand[k];
if(c+<=n) dis[c+][b]-=Rand[k];
if(d+<=m)dis[a][d+]-=Rand[k];
if(c+<=n&&d+<=m) dis[c+][d+]+=Rand[k]; } for(int i=;i<=n;i++)
{
long long now=;
for(int j=;j<=m;j++)
{
now+=dis[i][j];
if(i->=)
dis[i][j]=dis[i-][j]+now;
else
dis[i][j]=now;
}
} int ans=;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if(dis[i][j]%Rand[Map[i][j]]!=)ans++; printf("%d",ans);
return ; }
farm的更多相关文章
- SharePoint 2013: A feature with ID has already been installed in this farm
使用Visual Studio 2013创建一个可视web 部件,当右击项目选择"部署"时报错: "Error occurred in deployment step ' ...
- How To Collect ULS Log from SharePoint Farm
We can use below command to collect SharePoint ULS log from all servers in the Farm in PowerShell. M ...
- How To Restart timer service on all servers in farm
[array]$servers= Get-SPServer | ? {$_.Role -eq "Application"} $farm = Get-SPFarm foreach ( ...
- ZOJ 2412 Farm Irrigation
Farm Irrigation Time Limit: 2 Seconds Memory Limit: 65536 KB Benny has a spacious farm land to ...
- nginx+iis、NLB、Web Farm、Web Garden、ARR
nginx+iis实现负载均衡 在win2008R2上使用(NLB)网络负载均衡 NLB网路负载均衡管理器详解 [译文]Web Farm和Web Garden的区别? IIS负载均衡-Applicat ...
- 续并查集学习笔记——Closing the farm题解
在很多时候,并查集并不是一个完整的解题方法,而是一种思路. 通过以下题目来体会并查集逆向运用的思想. Description Farmer John and his cows are planning ...
- SharePoint Error - The current user is not an SharePoint Server farm administrator
错误截图 错误日志 位置:C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\LOGS 主要错误 The c ...
- hdu.1198.Farm Irrigation(dfs +放大建图)
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu Farm Irrigation
这题第一感觉是用搜索做,暴力就可以解决,这里将水管转换成一个个3*3的矩阵,然后搜素就可以了.写完之后确实一遍过掉了,31ms.附上代码: #include"iostream" # ...
- Web Fram 2 for IIS7.X(Microsoft Web Farm Framework)
Microsoft Web Farm Framework (WFF) 2.0 是微软开发的.基于IIS 7.x的小插件,能够帮助我们轻松实现Web网站的高性能.高可用性,用来在Web服务器群上提供和管 ...
随机推荐
- 洛谷 P1330 封锁阳光大学
题目描述 曹是一只爱刷街的老曹,暑假期间,他每天都欢快地在阳光大学的校园里刷街.河蟹看到欢快的曹,感到不爽.河蟹决定封锁阳光大学,不让曹刷街. 阳光大学的校园是一张由N个点构成的无向图,N个点之间由M ...
- ajax报错问题的解决
背景:用ajax与服务器页面进行交互 问题:XMLHttpRequest.status==0并且XMLHttpRequest.readyState==0并且textStatus==error 关于XM ...
- vs和github同步开发步骤
首先,这是在visual studio中使用.需要了解关于vs同步github必不可少.下载安装破解什么的先完成vs. 1. 然后安装一个vs中使用github的插件.vs自带的下载.这个是下载地址. ...
- win10 多桌面 win+tab | ctrl+win+左右箭头
win10 多桌面 win+tab | ctrl+win+左右箭头
- pytest生成测试报告
生成JunitXML格式的测试报告 --junitxml=report\h.xml 生成result log 格式的测试报告 --resultlog=report\h.log 生成htm ...
- 通过例子理解 k8s 架构【转】
为了帮助大家更好地理解 Kubernetes 架构,我们部署一个应用来演示各个组件之间是如何协作的. 执行命令 kubectl run httpd-app --image=httpd --replic ...
- CPP-基础:char、BYTE、byte
一,C++语言的内建类型中没“BYTE”这么个类型.BYTE是WINDOWS Platform SDK中windef.h里面定义的:typedef unsigned char BYTE; 二,char ...
- H3C交换机系统时间设置漏洞
H3C交换机系统时间设置存在漏洞 1. 背景说明 由于在编写<主机房网络延伸实施方案>,调试H3C S5120S-28P-EI交换机时,发现交换机设置成现在的时间后,导致本地用户通过ssh ...
- 简单jQuery图片自适应宽度插件jQuery.imgAutoSize.js
(function ($) { var loadImg = function (url, fn) { var img = new Image(); img. ...
- 流程控制主while,for,python画金字塔,画9*9乘法表
5.6 自我总结 一.流程控制while 1.while while True: #while + 条件满足进行下面的循环 age = input('age:') #while 循环的内容 2.whi ...