SWPDGT - Editorial

@taran_1407 can you please explain the logic for the bonus part of this question… i.e.,

Can you solve it without explicitly doing swaps and then comparing?

I m not able to find solution for this. Please guide…

thank you so much for your testcase.

can anyone explain the setter solution
mx=max(mx,a210+b1+b210+a1);
if(b2) mx=max(mx,a210+b2+a110+b1);
if(a2) mx=max(mx,b110+a1+b210+a2);
if(a2 && b2) mx=max(mx,b210+a1+a210+b1);
i am not getting the logic behind this code

Whats wrong with this code…??

#include<bits//stdc++.h>
#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
string s1,s2;
cin>>s1>>s2;

	string ts1=s1;string ts2=s2;
	int os=stoi(s1)+stoi(s1);
	int l=0;
	int os1[4]={0};
	for(int i=0;i<s1.length();i++){
		for(int j=0;j<s2.length();j++){
			s1=ts1;s2=ts2;
			
			char a=s1[i];
			s1[i]=s2[j];
			s2[j]=a;
		//	cout<<"s1 "<<s1<<"s2 "<<s2<<endl;
			os1[l]=(stoi(s1)+stoi(s2));
			l++;
		}
	}
	int ma=INT_MIN;
	for(int i=0;i<4;i++){
		ma=max(os1[i],ma);
	}
	cout<<max(ma,os)<<endl;
	
	
}

}