比赛 期末考试2 评测结果 MMMMMMMMMM
题目名称 魔法 最终得分 0
用户昵称 杨蕙宇 运行时间 0.007 s
代码语言 C++ 内存使用 1.36 MiB
提交时间 2026-02-10 11:38:23
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=5e4+10;
const int K=5e3+20;
int n,k,q,tot;
int a[K][N];
void w1(int x,int y){
    tot++;
    for(int i=1;i<=n;i++){
        a[tot][i]=max(a[x][i],a[y][i]);
    }
}
void w2(int x,int y){
    tot++;
    for(int i=1;i<=n;i++){
        a[tot][i]=min(a[x][i],a[y][i]);
    }
}
int main(){
    freopen("breeding.in","r",stdin);
    freopen("breeding.out","w",stdout);
    cin>>n>>k>>q;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    tot=k;
    while(q--){
        int op,x,y;
        cin>>op>>x>>y;
        if(op==1){
            w1(x,y);
        } 
        else if(op==2){
            w2(x,y);
        }
        else{
            cout<<a[x][y]<<"\n";
        }
    }
    return 0;
}