CF878D.Magic Breeding
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have k creatures 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.
尼基塔和萨沙正在玩一款电脑游戏,游戏中需要培育一些魔法生物。初始时,他们拥有 k 个编号为 1 到 k 的生物。每个生物具有 n 种不同的特征。
萨沙拥有一种法术,可由两个给定的生物生成一个新的生物:新生物的每种特征值等于所用两个生物对应特征值的最大值。尼基塔也拥有一种类似的法术,但其法术生成的新生物的每种特征值等于所用两个生物对应特征值的最小值。新生成的生物将获得当前未使用的最小编号。
他们不断使用这些法术,并关注其新生物的某些特征。请帮助他们求出这些特征。
输入格式
The first line contains integers n, k 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 _a__i_1, _a__i_2, ..., a__in (1 ≤ a__ij ≤ 109) — characteristics of the i-th creature.
Each of the next q lines contains a query. The i-th of these lines contains numbers t__i, x__i and y__i (1 ≤ t__i ≤ 3). They denote a query:
- t__i = 1 means that Sasha used his spell to the creatures x__i and y__i.
- t__i = 2 means that Nikita used his spell to the creatures x__i and y__i.
- t__i = 3 means that they want to know the y__i-th characteristic of the x__i-th creature. In this case 1 ≤ y__i ≤ n.
It's guaranteed that all creatures' numbers are valid, that means that they are created before any of the queries involving them.
第一行包含三个整数 n、k 和 q(1 ≤ n ≤ 105,1 ≤ k ≤ 12,1 ≤ q ≤ 105)——分别表示特征数量、初始生物数量以及查询次数。
接下来的 k 行描述初始生物。第 i 行包含 n 个整数 ai1,ai2,…,ain(1 ≤ aij ≤ 109)——表示第 i 个生物的各项特征值。
接下来的 q 行每行描述一个查询。其中第 i 行包含三个数 ti、xi 和 yi(1 ≤ ti ≤ 3),表示如下查询:
- ti = 1 表示 Sasha 对生物 xi 和 yi 使用了他的法术;
- ti = 2 表示 Nikita 对生物 xi 和 yi 使用了他的法术;
- ti = 3 表示他们想查询第 xi 个生物的第 yi 项特征值;此时保证 1 ≤ yi ≤ n。
保证所有涉及的生物编号均有效,即:在任何相关查询发生前,这些生物均已创建。
输出格式
For each query with t__i = 3 output the corresponding characteristic.
对于每个满足 ti=3 的查询,输出对应的特征值。
输入输出样例
输入#1
2 2 4 1 2 2 1 1 1 2 2 1 2 3 3 1 3 4 2
输出#1
2 1
输入#2
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
输出#2
5 2 2 3 4
说明/提示
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.
在第一个样例中,萨沙创造了一个编号为 3 的生物,其特征为 (2,2);尼基塔创造了一个编号为 4 的生物,其特征为 (1,1)。之后,他们分别获知了生物 3 的第一项特征值和生物 4 的第二项特征值。
输入解题思路,AI测评打分。不知道怎么写?