比赛 期末考试2 评测结果 AATTTTTTTT
题目名称 魔法 最终得分 20
用户昵称 LikableP 运行时间 5.774 s
代码语言 C++ 内存使用 119.28 MiB
提交时间 2026-02-10 12:00:19
显示代码纯文本
#include <cstdio>
#include <algorithm>

const int MAXN = 5010;

struct Creature {
  int a[MAXN];
} a[MAXN << 1];

int n, k, q;
int creature;

int main() {
  #ifdef LOCAL
    freopen("!input.in", "r", stdin);
    freopen("!output.out", "w", stdout);
  #else
    freopen("breeding.in", "r", stdin);
    freopen("breeding.out", "w", stdout);
  #endif

  scanf("%d %d %d", &n, &k, &q);
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &a[i].a[j]);
    }
  }

  creature = k;
  while (q--) {
    int opt, x, y;
    scanf("%d %d %d", &opt, &x, &y);
    if (opt == 1) {
      ++creature;
      for (int i = 1; i <= n; ++i) {
        a[creature].a[i] = std::max(a[x].a[i], a[y].a[i]);
      }
    } else if (opt == 2) {
      ++creature;
      for (int i = 1; i <= n; ++i) {
        a[creature].a[i] = std::min(a[x].a[i], a[y].a[i]);
      }
    } else {
      printf("%d\n", a[x].a[y]);
    }
  }
  return 0;
}