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.

尼基塔和萨沙正在玩一款电脑游戏,游戏中需要培育一些魔法生物。初始时,他们拥有 kk 个编号为 11 到 kk 的生物。每个生物具有 nn 种不同的特征。

萨沙拥有一种法术,可由两个给定的生物生成一个新的生物:新生物的每种特征值等于所用两个生物对应特征值的最大值。尼基塔也拥有一种类似的法术,但其法术生成的新生物的每种特征值等于所用两个生物对应特征值的最小值。新生成的生物将获得当前未使用的最小编号。

他们不断使用这些法术,并关注其新生物的某些特征。请帮助他们求出这些特征。

输入格式

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.

第一行包含三个整数 nn、kk 和 qq(1 ≤ n ≤ 1051 \le n \le 10^5,1 ≤ k ≤ 121 \le k \le 12,1 ≤ q ≤ 1051 \le q \le 10^5)——分别表示特征数量、初始生物数量以及查询次数。

接下来的 kk 行描述初始生物。第 ii 行包含 nn 个整数 ai1, ai2, …, aina_{i1},\,a_{i2},\,\dots,\,a_{in}(1 ≤ aij ≤ 1091 \le a_{ij} \le 10^9)——表示第 ii 个生物的各项特征值。

接下来的 qq 行每行描述一个查询。其中第 ii 行包含三个数 tit_i、xix_i 和 yiy_i(1 ≤ ti ≤ 31 \le t_i \le 3),表示如下查询:

  • ti = 1t_i = 1 表示 Sasha 对生物 xix_i 和 yiy_i 使用了他的法术;
  • ti = 2t_i = 2 表示 Nikita 对生物 xix_i 和 yiy_i 使用了他的法术;
  • ti = 3t_i = 3 表示他们想查询第 xix_i 个生物的第 yiy_i 项特征值;此时保证 1 ≤ yi ≤ n1 \le y_i \le n。

保证所有涉及的生物编号均有效,即:在任何相关查询发生前,这些生物均已创建。

输出格式

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

对于每个满足 ti=3t_i = 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)(2,\,2);尼基塔创造了一个编号为 4 的生物,其特征为 (1, 1)(1,\,1)。之后,他们分别获知了生物 3 的第一项特征值和生物 4 的第二项特征值。

输入解题思路,AI测评打分。不知道怎么写?

首页