当前位置:网站首页>(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
2022-08-08 23:06:00 【AC__dream】
题目:
样例输入:
3 5
2 1 1 2 2 1 2
3 1 3 2 2 3 1 2 3 3
2 2 3 1 3 2 1
191415411
样例输出:
34417749
题意:有n个公司,第i个公司有mi个工作,每个工作对三个能力分别有数值要求,必须三个能力都达标才能胜任这份工作。一个人只要能胜任一个公司的任意一份工作那么他都能进入这个公司。
q次询问,每次询问一个三元组,代表一个人三个能力的数值,求这个人可以去多少个公司工作,强制在线。
对于每个公司我们不可能都处理一遍前缀和,因为10*400*400*400肯定会超时,由于我们只需要知道能否胜任某个公司的某个工作而不是全部的工作都要胜任,而且我们要存储多个公司的信息,所以我们只需要用二进制维护一下就行,对于第t个公司我们用第t位二进制位去维护该信息,这样的话就可以使得公司与公司之间互补干扰。然后直接O(1)查询即可。
下面是代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include <random>
using namespace std;
const int N=401,mod=998244353;
int f[N][N][N],s[2000005];
int lastans=0,seed;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int main()
{
int n,m;
n=read();m=read();
for(int i=1;i<=n;i++)
{
int t;
t=read();
for(int j=1;j<=t;j++)
{
int a,b,c;
a=read(),b=read(),c=read();
f[a][b][c]|=(1<<i);
}
}
for(int i=1;i<=400;i++)
for(int j=1;j<=400;j++)
for(int k=1;k<=400;k++)
f[i][j][k]|=f[i][j][k-1]|f[i][j-1][k]|f[i-1][j][k];
seed=read();
std::uniform_int_distribution<> u(1,400);
std::mt19937 rng(seed);
s[0]=1;
for(int i=1;i<=m;i++)
s[i]=1ll*s[i-1]*seed%mod;
long long anss = 0;
for(int i=1;i<=m;i++)
{
int IQ=(u(rng)^lastans)%400+1; // The IQ of the i-th friend
int EQ=(u(rng)^lastans)%400+1; // The EQ of the i-th friend
int AQ=(u(rng)^lastans)%400+1; // The AQ of the i-th friend
lastans=0;
for(int i=1;i<=n;i++)
lastans+=f[IQ][EQ][AQ]>>i&1;
anss = (anss+1ll*lastans*s[m-i]%mod)%mod;
}
printf("%lld\n", anss);
return 0;
}
边栏推荐
- 考证必看 | PMP扫盲贴+PMP材料
- stm32 利用 串口接收空闲中断 + dma 实现不定长度dma 接收
- The concept of GIL and pools
- 2021 RoboCom 世界机器人开发者大赛-本科组(决赛)7-4猛犸不上 Ban(最短路)
- Low-Light Image Enhancement via a Deep Hybrid Network阅读札记
- Ant Forest Offline crawlers automatically collect energy, raise chickens, and other operations
- LeetCode:正则表达式匹配
- Dynamic Host Configuration Protocol DHCP (DHCPv4)
- 让IPv6强大的关键——NDP邻居发现协议
- 【Tensorflow2】tensorflow1.x-tensorflow2.x一些接口的转变
猜你喜欢
随机推荐
Introduction to Qt (4) - Continuous playback of pictures (the use of two timers)
stm32使用spi1在slave 模式下 dma 读取数据
C language library function summary2019.10.31
bp神经网络的学习心得
应用层协议——RADIUS
ArcPy elements batch to dwg
PMP考点有哪些啊?
The concept of GIL and pools
CTF Attack and Defense World
Free ARP
如何搭建一套自己公司的知识共享平台
生活中无处不在的MPLS虚拟专用网
免费ARP
机器学习建模高级用法!构建企业级AI建模流水线
第二课:概率论
Kubernetes 资源核心原理
MPLS Virtual Private Network Everywhere in Life
【Verilog基础】PPA优化问题总结(含面积优化、速度优化)
按键精灵 删除文件 命令
机器学习之知识点(一)