/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Time Exceeded ≥2099ms ≥532.0 KiB
#3 Wrong Answer 12ms 532.0 KiB

Code

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

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i, j, op = 0;
    for(i=0;i<n;i++){
        for(j=0;j<n-1;j++){
            if((s[j]-'0')<(s[j+1]-'0')){
               swap(s[j],s[j+1]);
               op++;
            }
        }
    }

    cout<<op<<endl;
}

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

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1016 Swap sort
Contest
Brain booster - 1
Language
C++17 (G++ 13.2.0)
Submit At
2023-12-31 15:30:32
Judged At
2024-11-11 03:45:40
Judged By
Score
20
Total Time
≥2099ms
Peak Memory
≥532.0 KiB