/*
ID: neverchanje
PROG:
LANG: C++11
*/
#include<vector>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<set>
#include<queue>
#include<map>
using namespace std;
#define INF 1e9
#define maxn
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define mset(x) memset(x,0,sizeof(x))
typedef long long ll;
int kase, n, m, k, t;
int main(){
// freopen("a.txt","r",stdin);
// freopen(".out","w",stdout);
cin>>kase;
rep(ks,1,kase){
cin>>n>>m>>k;
map<pair<int,int>,int> forest;
int x,y,c;
rep(i,1,k){
cin>>x>>y>>c;
forest[make_pair(x,y)] = c;
}
printf("Case #%d:\n",ks);
cin>>t;
int q, a, b, ta, tb;
map<int, int> row;
map<int, int> col;
while(t--){
cin>>q>>a>>b;
if(q==1){
ta = row[a] == 0 ? a : row[a];
tb = row[b] == 0 ? b : row[b];
row[a] = tb;
row[b] = ta;
}
else if(q==2){
ta = col[a] == 0 ? a : col[a];
tb = col[b] == 0 ? b : col[b];
col[a] = tb;
col[b] = ta;
}
else{
ta = row[a]==0 ? a : row[a];
tb = col[b]==0 ? b : col[b];
cout<<forest[make_pair(ta,tb)]<<endl;
}
}
}
return 0;
}
/*
DESCRIPTION:
由于只是行与行,列与列进行交换,交换之后并不会改变其他行列。
水题
*/
hdu4941 map应用
最新推荐文章于 2018-12-10 23:09:50 发布