1 solutions

  • 0
    @ 2025-11-27 11:59:46

    C++ :

    #include <bits/stdc++.h>
    
    using namespace std;
    
    const int N = 1e5 + 5;
    int n, m, x, y, cnt[N];
    
    
    int main() {
        cin >> n >> m;
    
        while (m--) {
            cin >> x >> y;
            cnt[x]++;
            cnt[y]++;
        }
    
        long long s = 0;
    
        for(int i = 1; i <= n; i++){
            s += 1ll * cnt[i] * (cnt[i] - 1) / 2;
        }
    
        cout << s;
    
    }
    
    
    • 1

    Information

    ID
    124
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By