秋季练习

来源:互联网 发布:域名别名解析 编辑:程序博客网 时间:2024/04/27 16:53

来源:HDU5963

CCPC补题,怎么当时没发现规律呢,尴尬

HDU上面貌似make_pair用不起来貌似

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>#include <map>using namespace std;int n,m;int Qm;const int MAXN = 40010;int d[MAXN];map<pair<int,int> ,int> mp;pair<int,int>tmp;int main(){int T;scanf("%d",&T);while(T--){        int co,u,v;        memset(d,0,sizeof d);        mp.clear();        scanf("%d%d",&n,&m);        for(int i=1;i<n;i++){scanf("%d%d%d",&u,&v,&co);if(co == 1) {d[u] ++;d[v] ++;tmp.first = u;tmp.second = v;mp[tmp] = 1;tmp.first = v;tmp.second = u;mp[tmp] = 1;}        }        int op;        for(int i=1;i<=m;i++){            scanf("%d",&op);            if(op){scanf("%d%d%d",&u,&v,&co);tmp.first = u;tmp.second = v;                if(mp[tmp] != co){                    if(co){mp[tmp] = 1;tmp.first = v;tmp.second = u;mp[tmp] = 1;d[u] ++;d[v] ++;                    }                    else {tmp.first = u;tmp.second = v;mp[tmp] = 0;tmp.first = v;tmp.second = u;mp[tmp] = 0;d[u] --;d[v] --;                    }                }            }            else{int rt;scanf("%d",&rt);                if(d[rt] & 1) puts("Girls win!");                else puts("Boys win!");            }        }}return 0;}


1 0
原创粉丝点击