/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 2ms 532.0 KiB
#3 Wrong Answer 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
using namespace chrono;

void solve() {
    int n; string s;
    cin >> n >> s;
    int z = 0, o = 0;
    long long zo = 0, oz = 0;
    for (char c : s) {
        if (c == '1') {
            zo += z;
            o++;
        } else {
            oz += o;
            z++;
        }
    }
    cout << min(oz, zo) << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t; cin >> t; while (t--)
        solve();
}

Information

Submit By
Type
Submission
Problem
P1016 I. Swap sort
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 18:38:19
Judged At
2025-07-14 18:38:19
Judged By
Score
20
Total Time
2ms
Peak Memory
532.0 KiB