当前位置:网站首页>Three body attack ---- three-dimensional difference + dichotomy + coordinate mapping
Three body attack ---- three-dimensional difference + dichotomy + coordinate mapping
2022-07-22 14:42:00 【Wawa source】
Topic website
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2000010;
int A,B,C,m;
int s[N],b[N],tmp[N],op[N/2][7];
int get(int i,int j,int k)
{
return (i*B+j)*C+k;
}
void add(int x1,int x2,int y1,int y2,int z1,int z2,int c)
{
b[get(x1,y1,z1)]+=c;
b[get(x2+1,y1,z1)]-=c;
b[get(x1,y2+1,z1)]-=c;
b[get(x1,y1,z2+1)]-=c;
b[get(x2+1,y2+1,z1)]+=c;
b[get(x2+1,y1,z2+1)]+=c;
b[get(x1,y2+1,z2+1)]+=c;
b[get(x2+1,y2+1,z2+1)]-=c;
}
void sub(int x1,int x2,int y1,int y2,int z1,int z2,int c)
{
tmp[get(x1,y1,z1)]-=c;
tmp[get(x2+1,y1,z1)]+=c;
tmp[get(x1,y2+1,z1)]+=c;
tmp[get(x1,y1,z2+1)]+=c;
tmp[get(x2+1,y2+1,z1)]-=c;
tmp[get(x2+1,y1,z2+1)]-=c;
tmp[get(x1,y2+1,z2+1)]-=c;
tmp[get(x2+1,y2+1,z2+1)]+=c;
}
bool check(int mid)
{
memcpy(tmp,b,sizeof b);
for(int i=0;i<mid;i++)
{
int x1=op[i][0],x2=op[i][1];
int y1=op[i][2],y2=op[i][3];
int z1=op[i][4],z2=op[i][5];
int c=op[i][6];
sub(x1,x2,y1,y2,z1,z2,c);
}
memset(s,0,sizeof s);
for(int i=1;i<=A;i++)
for(int j=1;j<=B;j++)
for(int k=1;k<=C;k++)
{
s[get(i,j,k)]=tmp[get(i,j,k)]+
s[get(i-1,j,k)]+s[get(i,j-1,k)]+s[get(i,j,k-1)]-
s[get(i-1,j-1,k)]-s[get(i-1,j,k-1)]-s[get(i,j-1,k-1)]+
s[get(i-1,j-1,k-1)];
if(s[get(i,j,k)]<0)
return true;
}
return false;
}
signed main()
{
cin>>A>>B>>C>>m;
for(int i=1;i<=A;i++)
for(int j=1;j<=B;j++)
for(int k=1;k<=C;k++)
{
cin>>s[get(i,j,k)];
add(i,i,j,j,k,k,s[get(i,j,k)]);
}
for(int i=0;i<m;i++)
for(int j=0;j<7;j++)
cin>>op[i][j];
int l=1,r=m;
while(l<r)
{
int mid=l+r>>1;
if(check(mid))r=mid;
else l=mid+1;
}
cout<<r<<'\n';
}
边栏推荐
- Controllable text generation series-a survey of controllable text generation using transformer based pre trained
- 要想上云之旅中不被“甩掉”,云服务供应商的企业生命力是关键
- UiPath被独立研究机构评为中国RPA市场领导者称号
- 堆(优先级队列)
- 征信衍生、信用卡数据场景如何做好分析,这一种时序特征方法得学学|金融信用分析师必学内容
- 时间复杂度与复杂度
- The difference and connection between cookies and seesion
- 我的创作纪念日
- 【Pingtunnel工具教程】利用ICMP隧道技术进行ICMP封装穿透防火墙
- Cluster configuration and verification of MySQL Cluster (4)
猜你喜欢
How to do a good job in analyzing credit derivatives and credit card data scenarios? This time series feature method needs to be learned | what financial and credit analysts must learn
Client and server of grpc magiconion Library (case version)
【Pingtunnel工具教程】利用ICMP隧道技术进行ICMP封装穿透防火墙
Mysql索引分類及其使用實例
[cicadaplayer] the problem that the release cannot debug at breakpoints
OS7-资源的死锁
[wechat applet] choosebao - the Savior of choice difficulties
迟迟不发业绩预告,京东方此时无声胜有声?
MySql集群之主从复制(一)
Master slave replication of MySQL Cluster (I)
随机推荐
【Cicadaplayer】Release无法断点调试的问题
C#接口基础知识重构
网络分析---并查集上做差分
BERTopic
【云原生之kubernetes】在kubernetes集群下的jobs与cronjobs管理
Some experience of code specification
【Try to Hack】Syn Flood和CC攻击
RPC核心模块汇总
UDS02-根据标识符读取数据服务【ServiceID = 0x22】
【服务器数据恢复】华为某型号服务器raid6数据恢复案例
url链接中特殊字符转义方法
DCM09- ReadDataByIdentifier ($22)的功能和配置【基于DaVinci Configurator Classic】
三体攻击----三维差分+二分+坐标映射
rexroth比例阀4WRPEH6C3B04L-3X/M/24F1-885
2022r1 fast opening pressure vessel operation test and simulation test
刚考完 热的 PCA 国家证书 考了个满分丢。 公司不敢B出来 怕被 下面NB的公司锤。。
UiPath被独立研究机构评为中国RPA市场领导者称号
Rexroth proportional valve 4wrpeh6c3b04l-3x/m/24f1-885
Usage and cases of regexp of MySQL statement
OS09- AutoSAR OS事件机制和实例解析