1 条题解

  • 0
    @ 2025-11-3 0:09:35

    C++ :

    #include <bits/stdc++.h>
    
    using namespace std;
    
    using ll = long long;
    
    const int S = 1 << 26;
    
    ll n, res, dp;
    ll f[S];
    string s;
    
    int main() {
        cin >> n >> s;
        
        for (int i = 0; i < n; i++) {
            dp ^= (1 << (s[i] - 'a'));
            if (dp == 0) res++;
            res += f[dp];
            f[dp]++;
        }
    
        cout << res << '\n';
    
        return 0;
    }
    
    
    
    • 1

    信息

    ID
    5622
    时间
    1000ms
    内存
    1024MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者