当前位置:网站首页>(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
2022-08-01 04:47: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;
}
边栏推荐
猜你喜欢
Step by step hand tearing carousel Figure 3 (nanny level tutorial)
最新 955 不加班的公司名单
UE4 模型OnClick事件不生效的两种原因
出现Command ‘vim‘ is available in the following places,vim: command not found等解决方法
7月编程排行榜来啦!这次有何新变化?
mysql中解决存储过程表名通过变量传递的方法
【无标题】
TypeScript simplifies running ts-node
MySQL-数据定义语言-DDLdatebase define language
智芯传感输液泵压力传感器 为精准智能控制注入科技“强心剂”
随机推荐
UE4 rays flashed from mouse position detection
MySQL4
初识shell脚本
How to promote new products online?
Message queue design based on mysql
高数 | 【重积分】线面积分880例题
Difference Between Compiled and Interpreted Languages
Flutter Tutorial 02 Introduction to Flutter Desktop Program Development Tutorial Run hello world (tutorial includes source code)
基于Arduino制作非接触式测温仪
How to write a high-quality digital good article recommendation
阿叶的目标
Typescript20 - interface
MySQL-数据定义语言-DDLdatebase define language
Excel做题记录——整数规划优化模型
博客系统(完整版)
typescript28 - value of enumeration type and data enumeration
The Flow Of Percona Toolkit pt-table-checksum
「以云为核,无感极速」顶象第五代验证码
Game Theory (Depu) and Sun Tzu's Art of War (42/100)
在沈自所的半年总结