b [ j ] - a [ i ] = b [ idx . second ] - a [ idx . first ] b [ j ] - b [ idx . second ] = a [ i ] = a [ idx . first ] So sub - arrays are a [ idx . first + 1. . . i ] and b [ idx . second + 1. . . j ]
if ( swap ) { pair < int , int > idx = index [ b [ j ] - a [ i ] ] ; printAns ( idx . second + 1 , j , 1 ) ; printAns ( idx . first + 1 , i , 2 ) ; } else { pair < int , int > idx = index [ b [ j ] - a [ i ] ] ; printAns ( idx . first + 1 , i , 1 ) ; printAns ( idx . second + 1 , j , 2 ) ; } return ; }