https://leetcode.com/problems/couples-holding-hands/
class Solution {
public:
int minSwapsCouples(vector<int>& row) {
int res = 0, len = row.size();
for(int i=0; i<len; i+=2){
if(row[i+1]==(row[i]^1)) continue; //表示这一对是配对成功的
res += 1;
for(int j=i+1; j<len; j++){
if(row[j]==(row[i]^1)){
row[j] = row[i+1];
row[i+1] = row[i]^1;
break;
}
}
}
return res;
}
};