/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 444.0 KiB
#2 Wrong Answer 15ms 1.469 MiB
#3 Wrong Answer 14ms 1.422 MiB

Code

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;
        unordered_map<char, int> freq;
        for (char c : s) {
            freq[c]++;
        }

        int swaps = 0;
        for (auto& p : freq) {
            swaps += p.second / 2;
        }

        cout << 2 * swaps << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1038 Do not touch my string
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 16:34:21
Judged At
2024-11-11 03:33:00
Judged By
Score
10
Total Time
15ms
Peak Memory
1.469 MiB