Codeforces judge giving wrong output for my code

Правка en3, от rinku11, 2021-12-16 20:17:02

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

Теги implemention

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский rinku11 2021-12-16 20:29:58 119
en4 Английский rinku11 2021-12-16 20:24:19 977
en3 Английский rinku11 2021-12-16 20:17:02 960
en2 Английский rinku11 2021-12-16 20:00:50 73
en1 Английский rinku11 2021-12-16 19:59:10 346 I checked thoroughly but I couldn't find the error (published)