当前位置:网站首页>(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;
}
边栏推荐
- 解决ffmpeg使用screen-capture-recorder录屏,有屏幕缩放的情况下录不全的问题
- 【愚公系列】2022年07月 Go教学课程 024-函数
- typescript23-tuple
- lambda
- 数组问题之《两数之和》以及《三数之和 》
- This article takes you to understand the past and present of Mimir, Grafana's latest open source project
- typescript28 - value of enumeration type and data enumeration
- mysql中解决存储过程表名通过变量传递的方法
- Difference Between Compiled and Interpreted Languages
- 风险策略调优中重要的三步分析法
猜你喜欢

怀念故乡的面条

Software Testing Weekly (Issue 82): In fact, all those who are entangled in making choices already have the answer in their hearts, and consultation is just to get the choice that they prefer.

typescript25 - type assertion

程序员代码面试指南 CD15 生成窗口最大值数组

leetcode:126. Word Solitaire II

Simulation of Active anti-islanding-AFD Active Anti-islanding Model Based on Simulink

MySQL3

The maximum quantity leetcode6133. Grouping (medium)

y83.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十四)

故乡的素描画
随机推荐
FFmpeg 搭建本地屏幕录制环境
【愚公系列】2022年07月 .NET架构班 085-微服务专题 Abp vNext微服务网关
【云原生之kubernetes实战】kubernetes集群的检测工具——popeye
UE4 从鼠标位置射出射线检测
7 行代码搞崩溃 B 站,原因令人唏嘘!
初识shell脚本
Unity's primary method for implementing PlanarReflection under the BuildIn rendering pipeline
typescript23-tuple
请问shake数据库中想把源的db0的数据同步到目的db5,参数怎么设置呢?
PMP 项目资源管理
博客系统(完整版)
MySQL3
PMP工具与技术总结
时时刻刻保持敬畏之心
干货!如何使用仪表构造SRv6-TE性能测试环境
Write a method to flatten an array and deduplicate and sort it incrementally
ModuleNotFoundError: No module named ‘tensorflow.keras‘报错信息的解决方法
Software Testing Interview (3)
56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)
Software Testing Weekly (Issue 82): In fact, all those who are entangled in making choices already have the answer in their hearts, and consultation is just to get the choice that they prefer.