比赛 期末考试2 评测结果 AATTTTTMTT
题目名称 魔法 最终得分 20
用户昵称 dream 运行时间 5.353 s
代码语言 C++ 内存使用 31.57 MiB
提交时间 2026-02-10 12:12:53
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=100005+15;
int n,k,q;
int a[15][N];
struct node{
	int op,x,y;
}b[N];
int cnt;
int solve(int xx,int yy){
	if(xx<=k) return a[xx][yy];
	else{
		if(b[xx].op==1){
			return max(solve(b[xx].x,yy),solve(b[xx].y,yy));
		}
		else{
			return min(solve(b[xx].x,yy),solve(b[xx].y,yy));
		}
	}
}
int main(){
	freopen("breeding.in","r",stdin);
	freopen("breeding.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k>>q;
	cnt=k;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=q;i++){
		int op,x,y;
		cin>>op>>x>>y;
		if(op==1){
			b[++cnt]={op,x,y};
		}
		else if(op==2){
			b[++cnt]={op,x,y};
		}
		else{
			cout<<solve(x,y)<<"\n";
		}
	}
	return 0;
}