/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
   int t;
   cin >>t;
   while(t--){
    int a, m;
    cin >> a >> m;
    string s;
    cin >>s;
    int i=0;
    int cnt=0;
    int j = a - 1;

    while(j >= i){
        if(s[i] != s[j]){
            if(s[i] > s[j]){
                swap(s[j], s[i]);
                cnt++;
            }

        }
            else{
            if(s[i] < s[i-1]){
                swap(s[i], s[i-1]);
                cnt++;
            }
            }
            i++; j--;
        if(cnt == m) break;


    }

    cout<<s<<endl;
   }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1058 Lexicographically Smallest String
Contest
Sylhet ICPC 2024 Collaborative Challenge: Episode 2
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-30 12:15:07
Judged At
2024-11-11 02:34:41
Judged By
Score
5
Total Time
2ms
Peak Memory
484.0 KiB