比赛 期末考试2 评测结果 AATTTTTMTT
题目名称 魔法 最终得分 20
用户昵称 梦那边的美好ME 运行时间 5.308 s
代码语言 C++ 内存使用 34.31 MiB
提交时间 2026-02-10 11:54:35
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll n,m,q;
ll num[15][110000];
ll tot;
ll a[110000][5];

ll dfs(ll x,ll y){
	if(x<=m){
		return num[x][y];
	}
	if(a[x][1]==1){
		return max(dfs(a[x][2],y),dfs(a[x][3],y));
	}
	else{
		return min(dfs(a[x][2],y),dfs(a[x][3],y));
	}
}

int main(){
	freopen("breeding.in","r",stdin);
	freopen("breeding.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>q;
	tot=m;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			cin>>num[i][j];
		}
	}
	while(q--){
		ll op,x,y;
		cin>>op>>x>>y;
		if(op==1){
			a[++tot][1]=1;
			a[tot][2]=x,a[tot][3]=y;
		}else if(op==2){
			a[++tot][1]=2;
			a[tot][2]=x,a[tot][3]=y;
		}else{
			int ans=dfs(x,y);
			cout<<ans<<"\n"; 
		}
	}
	return 0;
}