Here is the question link which I solved-:https://mirror.codeforces.com/contest/1617/problem/A Here is my submission code-:
include<bits/stdc++.h>
using namespace std;
define krishna ios_base::sync_with_stdio(false)
define radhe cin.tie(NULL)
define basuri cout.tie(NULL)
define ll long long int
define nl endl
int main() { krishna; radhe,basuri; int t; cin>>t; while(t--){ string s,t; cin>>s>>t; map<char,int>mp; int cnt1,cnt2,cnt3; int size=s.size(); for(int i=0;i<size;i++){ mp[s[i]]++; } int x=mp['a']; int y=mp['b']; int z=mp['c']; if(x>0) cnt1++; if(y>0) cnt2++; if(z>0) cnt3++; int cnt4=cnt1+cnt2+cnt3; int cnt5=mp['a']+mp['b']+mp['c']; string m=s; sort(m.begin(),m.end()); if((t!="abc")||(cnt4<3)){ cout<<m<<endl; } else{ int p=x,q=cnt5-1; while(p<q){ swap(m[p],m[q]); p++,q--; } cout<<m<<endl; } } return 0; }
This code works fine in all other IDE (CodeChef,VsCode,Hackerrank) .But when I submit my code on codeforces running contest it gives me errors. Plz, anybody help me out.