Help in alternate version of "Chefina and Swaps"

In long challenge 2020, question Chefina and Swaps.
My problem is, what if an addition constraint A_i can only be swap with B_i (1≤i≤N).
what approach can I take?

#include****
#include****
using namespace std;
int main()
{
int Ai = 10, Bi = 20;
clog << "Before swapping Ai :- " << Ai << " and Bi :- " << Bi << endl;
swap(Ai, Bi);
clog << "After swapping Ai :- " << Ai << " and Bi :- " << Bi << endl;
}strong text

I think it’s helpful for you.

Your problem is strictly harder than this one, which is rated 2300 on CF… have fun with it, I don’t know how to do it

1 Like