Sort by

recency

|

9 Discussions

|

  • + 0 comments

    Today, gaming platforms offer a multitude of entertainment options,

  • + 1 comment

    This problem about choosing node pairs in a weighted tree really reminds me of how resource management in Hay Day feels—limited moves can make or break your progress. Just like in the game where waiting or grinding slows you down, here Andy has to pick paths carefully to guarantee a win. It’s like having the haydaymodapk that removes limits and lets you strategize freely without restrictions—except in this tree game, your move choices shape everything!

  • + 0 comments

    Today, gaming platforms offer a multitude of entertainment options, and among them, those operating in the Sweepstakes format stand out in particular. For example, on the https://sixty6.com/promotions website, you can find many interesting games that allow you to enjoy the thrill of gambling without using real money. It is a great place for those who love to feel the adrenaline rush and try their luck. And to find out about the latest offers and bonuses, be sure to visit the promotions page. Here you will find many interesting opportunities that will make your gaming experience even more exciting.

  • + 0 comments

    The objective of the geometry dash game is for the players to avoid colliding with obstacles by jumping over them.

  • + 0 comments

    C++ Solution

    #include <bits/stdc++.h>
    
    using namespace std;
    
    typedef unsigned long long ULL;
    
    const int maxn = 1e5 + 100;
    int T, n;
    vector<pair<int, ULL>> Edge[maxn * 5];
    
    ULL Hash(ULL w){
        return w * 747474747 + 447474747;
    }
    
    map<ULL,int>mp;
    
    void dfs(int u, int fa, ULL Ha){
        mp[Ha]++;
        for(int i = 0; i < Edge[u].size(); i++){
            int v = Edge[u][i].first;
            ULL w = Edge[u][i].second;
            if(v == fa) continue;
            dfs(v, u, Ha ^ w);
        }
    }
    
    int main(){
        scanf("%d", &T);
        int w, u, v;
        while(T--){
            scanf("%d", &n);
            mp.clear();
            for(int i = 0; i < n; i++) Edge[i].clear();
            for(int i = 0; i < n - 1; i++){
                scanf("%d %d %d", &u, &v, &w);
                u--; v--;
                Edge[u].push_back(make_pair(v, Hash(w)));
                Edge[v].push_back(make_pair(u, Hash(w)));
            }
            ULL ans = (1ULL * n * (n - 1)) / 2;
            dfs(0, -1, 0);
            for(map<ULL, int>::iterator it = mp.begin(); it != mp.end(); it++) {
                ans -= (it->second * (it->second - 1)) / 2;
            }
            cout << ans << endl;
        }
        return 0;
    }