博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF878D D. Magic Breeding bitset
阅读量:6118 次
发布时间:2019-06-21

本文共 2666 字,大约阅读时间需要 8 分钟。

D. Magic Breeding
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have kcreatures numbered from 1 to k. Creatures have n different characteristics.

Sasha has a spell that allows to create a new creature from two given creatures. Each of its characteristics will be equal to the maximum of the corresponding characteristics of used creatures. Nikita has a similar spell, but in his spell, each characteristic of the new creature is equal to the minimum of the corresponding characteristics of used creatures. A new creature gets the smallest unused number.

They use their spells and are interested in some characteristics of their new creatures. Help them find out these characteristics.

Input

The first line contains integers nk and q (1 ≤ n ≤ 105, 1 ≤ k ≤ 12, 1 ≤ q ≤ 105) — number of characteristics, creatures and queries.

Next k lines describe original creatures. The line i contains n numbers ai1, ai2, ..., ain (1 ≤ aij ≤ 109) — characteristics of the i-th creature.

Each of the next q lines contains a query. The i-th of these lines contains numbers tixi and yi (1 ≤ ti ≤ 3). They denote a query:

  • ti = 1 means that Sasha used his spell to the creatures xi and yi.
  • ti = 2 means that Nikita used his spell to the creatures xi and yi.
  • ti = 3 means that they want to know the yi-th characteristic of the xi-th creature. In this case 1 ≤ yi ≤ n.

It's guaranteed that all creatures' numbers are valid, that means that they are created before any of the queries involving them.

Output

For each query with ti = 3 output the corresponding characteristic.

Examples
input
Copy
2 2 4 1 2 2 1 1 1 2 2 1 2 3 3 1 3 4 2
output
Copy
2 1
input
Copy
5 3 8 1 2 3 4 5 5 1 2 3 4 4 5 1 2 3 1 1 2 1 2 3 2 4 5 3 6 1 3 6 2 3 6 3 3 6 4 3 6 5
output
Copy
5 2 2 3 4
Note

In the first sample, Sasha makes a creature with number 3 and characteristics (2, 2). Nikita makes a creature with number 4 and characteristics (1, 1). After that they find out the first characteristic for the creature 3 and the second characteristic for the creature 4.

题目还是很好懂的吧

一开始的时候,给你k个怪兽,每个怪兽有n个属性。

然后现在你有三个操作:
第一个操作是用x和y怪物生成一个新的怪物,这个怪物的属性是x和y的最大值
第二个操作是用x和y怪物生成一个新的怪物,这个怪物的属性是x和y的最小值
第三个操作是询问第x个怪物的第y个属性是多少。

用并查集维护?不太行啊,这么多操作呢,根本无法模拟

这个bitset很有灵性

&用来取大,|用来取小

#include
using namespace std;const int N=1e6+5;bitset<4096>S[N];int a[12][N];int n,k,q;int main(){ scanf("%d%d%d",&n,&k,&q); for(int i=0; i
>Q; for(int i=0; i

 

转载于:https://www.cnblogs.com/BobHuang/p/9630562.html

你可能感兴趣的文章
------__________________________9余数定理-__________ 1163______________
查看>>
webapp返回上一页 处理
查看>>
新安装的WAMP中phpmyadmin的密码问题
查看>>
20172303 2017-2018-2 《程序设计与数据结构》第5周学习总结
查看>>
eclipse中将一个项目作为library导入另一个项目中
查看>>
Go语言学习(五)----- 数组
查看>>
Android源码学习之观察者模式应用
查看>>
Content Provider的权限
查看>>
416. Partition Equal Subset Sum
查看>>
centos7.0 64位系统安装 nginx
查看>>
数据库运维平台~自动化上线审核需求
查看>>
注解开发
查看>>
如何用 Robotframework 来编写优秀的测试用例
查看>>
Django之FBV与CBV
查看>>
Vue之项目搭建
查看>>
app内部H5测试点总结
查看>>
Docker - 创建支持SSH服务的容器镜像
查看>>
[TC13761]Mutalisk
查看>>
三级菜单
查看>>
Data Wrangling文摘:Non-tidy-data
查看>>