题目链接:hdu 4941 Magical Forest
题目大意:给定N,M和K,表示在一个N*M的棋盘上有K个棋子,给出K个棋子的位置和值,然后是Q次操作,对应的是:
1 a b :交换a和b两行
2 a b : 交换a和b两列
3 a b :查询a b这个位置上棋子的值,没有棋子的话输出0
解题思路:一开始X[i]=i,X[j]=j,如果需要交换i和j,那么就令X[i]=j,X[j]=i即可,因为N和M很大,所以用map映射。
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> pi......
阅读全文