Codeforces judge giving wrong output for my code

Revision en3, by rinku11, 2021-12-16 20:17:02

Here is the question link which I solved-:https://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.

Tags implemention

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English rinku11 2021-12-16 20:29:58 119
en4 English rinku11 2021-12-16 20:24:19 977
en3 English rinku11 2021-12-16 20:17:02 960
en2 English rinku11 2021-12-16 20:00:50 73
en1 English rinku11 2021-12-16 19:59:10 346 I checked thoroughly but I couldn't find the error (published)