标签:style color io for ar line amp new
模拟大法保平安_(:зゝ∠)_
#include <cstdio> #include <map> #include <set> #include <algorithm> using namespace std; const int N = 1; struct node{ int x, y, val; node(int a=0,int b=0,int c=0):x(a),y(b),val(c){} bool operator<(const node&a)const{ if(a.x!=x)return a.x<x; return a.y<y; } }; set<node>s; set<node>::iterator it; map<int, int> mp; map<int, int> mp2; int main() { int T; scanf("%d", &T); for(int cas = 1; cas <= T; cas ++){ mp.clear();mp2.clear();s.clear(); int n, m, k, x, y, p; scanf("%d%d%d", &n, &m, &k); while(k-- > 0) { scanf("%d%d%d", &x, &y, &p); s.insert(node(x, y ,p)); if(mp.find(x)==mp.end())mp[x] = x; if(mp2.find(y)==mp2.end())mp2[y] = y; } scanf("%d", &k); printf("Case #%d:\n", cas); while(k-- > 0) { scanf("%d%d%d", &p, &x, &y); if(p == 1) { if(mp.find(x)==mp.end())mp[x] = x; if(mp.find(y)==mp.end())mp[y] = y; int tmp = mp[x]; mp[x] = mp[y]; mp[y] = tmp; } else if(p == 2) { if(mp2.find(x)==mp2.end())mp2[x] = x; if(mp2.find(y)==mp2.end())mp2[y] = y; int tmp = mp2[x]; mp2[x] = mp2[y]; mp2[y] = tmp; } else { it = s.find(node(mp[x],mp2[y],0)); if(it == s.end()) puts("0"); else printf("%d\n", it->val); } } } return 0; }
HDU 4941 Magical Forest _(:зゝ∠)_ 模拟题,布布扣,bubuko.com
HDU 4941 Magical Forest _(:зゝ∠)_ 模拟题
标签:style color io for ar line amp new
原文地址:http://blog.csdn.net/qq574857122/article/details/38518261