Why i am getting WA for this/? my approach is to divide odd and even number into two parts and check the count of odd numbers then answer
My code
#include <iostream>
#include <iostream>
#include<vector>
typedef long long int ll;
#include<set>
#include<map>
#include <bits/stdc++.h>
#include<stack>
#include<algorithm>
#include<limits>
#define fastio() (ios_base::sync_with_stdio(false), cin.tie(NULL),cout.tie(NULL));
int expo(int a, int n){int res = 1; while(n){ if(n&1) {res *= a; --n;} else {a *= a; n >>= 1;}}return res;}
using namespace std;
#include <algorithm>
#include<string>
int min(int a, int b){if(a >= b) return b; else return a;}
int max(int a, int b){if(a >= b) return a; else return b;}
void printset(set<ll> s1, set<ll> s2){
for(auto i : s1){
cout << i << " ";
}
for(auto i : s2){
cout << i << " ";
}
cout << endl;
}
void solve(){
ll t; cin >> t;
while(t--){
ll n; cin >> n;
set<ll> e,o;
for(int i = 0; i < n; i++){
int a; cin >> a;
if(a%2) o.insert(a);
else e.insert(a);
}
if(o.size() == 0) cout << -1 << endl;
else if(o.size()%2 == 0){
printset(o, e);
}else{
cout << -1 << endl;
}
}
}
int main(){
solve();
}
Problem Link: ADJLOVE Problem - CodeChef