当前位置:网站首页>(2022 Nioke Duo School IV) D-Jobs (Easy Version) (3D prefix or)
(2022 Nioke Duo School IV) D-Jobs (Easy Version) (3D prefix or)
2022-08-01 04:50:00 【AC__dream】
Title:
Sample input:
3 52 1 1 2 2 1 23 1 3 2 2 3 1 2 3 32 2 3 1 3 2 1191415411
Sample output:
34417749
The meaning of the question: There are n companies, and the i-th company has mi jobs. Each job has numerical requirements for three abilities, and all three abilities must meet the standards to be qualified for the job.As long as a person is competent for any job in a company, he can enter the company.
Q times of inquiries, each time a triplet, representing the values of a person's three abilities, ask how many companies this person can go to work, and force online.
We can't do the prefix sum for every company because 10*400*400*400 will definitely time out, since we just need to know if we canCompetent for a certain job of a certain company, not all jobs, and we want to store the information of multiple companies, so we only need to maintain it with binary, for the t th companyWe use the t-th bit to maintain this information, so that we can make complementary interference between companies.Then it can be directly O(1) query.
Here is the code:
#include#include#include#include#include#include 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<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 friendint EQ=(u(rng)^lastans)%400+1; // The EQ of the i-th friendint AQ=(u(rng)^lastans)%400+1; // The AQ of the i-th friendlastans=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;}
边栏推荐
- Visual Studio提供的 Command Prompt 到底有啥用
- Mysql中的数据类型和运算符
- IJCAI2022 | Hybrid Probabilistic Reasoning with Algebraic and Logical Constraints
- 初识shell脚本
- JS new fun(); class and instance JS is based on object language Can only act as a class by writing constructors
- Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation
- TypeScript simplifies running ts-node
- How to promote new products online?
- Dynamic Programming 01 Backpack
- 怀念故乡的面条
猜你喜欢
typescript28-枚举类型的值以及数据枚举
typescript27-枚举类型呢
智芯传感输液泵压力传感器 为精准智能控制注入科技“强心剂”
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
leetcode:126. Word Solitaire II
scheduleWithFixedDelay和scheduleAtFixedRate的区别
MySQL-DML语言-数据库操作语言-insert-update-delete-truncate
Valentine's Day Romantic 3D Photo Wall [with source code]
C# | 使用Json序列化对象时忽略只读的属性
风险策略调优中重要的三步分析法
随机推荐
UE4 从鼠标位置射出射线检测
API Design Notes: The pimpl trick
数组问题之《两数之和》以及《三数之和 》
MySQL-数据操作-分组查询-连接查询-子查询-分页查询-联合查询
typescript24 - type inference
API设计笔记:pimpl技巧
Write a method to flatten an array and deduplicate and sort it incrementally
typescript26 - literal types
Character encoding and floating point calculation precision loss problem
剑指 Offer 68 - II. 二叉树的最近公共祖先
李迟2022年7月工作生活总结
Make your Lottie support word wrapping in text fields
UE4 rays flashed from mouse position detection
Visual Studio提供的 Command Prompt 到底有啥用
这里有110+公开的专业数据集
typescript26-字面量类型
A way to deal with infinite debugger
请问shake数据库中想把源的db0的数据同步到目的db5,参数怎么设置呢?
Invalid classes inferred from unique values of `y`. Expected: [0 1 2], got [1 2 3]
/etc/fstab