http://acm.hdu.edu.cn/showproblem.php?pid=5963

题目大意:中文题

思路:看ICPC camp好了,简单易懂:https://async.icpc-camp.org/d/628-2016     上面的C题

//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define haha printf("haha\n")
const int maxn = + ;
struct Node{
int to, val;
};
vector<Node> G[maxn];
int n, m;
int ans[maxn]; int main(){
int t; cin >> t;
while (t--){
scanf("%d%d", &n, &m);
for (int i = ; i <= n; i++) G[i].clear();
for (int i = ; i < n; i++){
int u, v, val;
scanf("%d%d%d", &u, &v, &val);
G[u].pb(Node{v, val}); G[v].pb(Node{u, val});
}
memset(ans, , sizeof(ans));
for (int i = ; i <= n; i++){
for (int j = ; j < G[i].size(); j++){
ans[i] += G[i][j].val;
}
}
for (int i = ; i <= m; i++){
int ty; scanf("%d", &ty);
if (ty == ){
int root; scanf("%d", &root);
if (ans[root] % ) printf("Girls win!\n");
else printf("Boys win!\n");
}
else if (ty == ){
int u, v, val;
scanf("%d%d%d", &u, &v, &val);
for (int j = ; j < G[u].size(); j++){
if (G[u][j].to == v){
if (val == G[u][j].val) break;
else {
G[u][j].val = val;
if (val == ) ans[u]++, ans[v]++;
else ans[u]--, ans[v]--;
}
}
}
for (int j = ; j < G[v].size(); j++){
if (G[v][j].to == u){
G[v][j].val = val;
break;
}
}
}
}
}
return ;
}
04-25 06:08