Codeforces 1370B. GCD Compression Solution
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
Solution in C++:
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,n,i,a,c,j;
- cin>>t;
- while(t--)
- {
- c=0;
- vector<int>odd,even;
- cin>>n;
- for(i=1; i<=2*n; i++)
- {
- cin>>a;
- if(a%2==0)
- even.push_back(i);
- else
- odd.push_back(i);
- }
- for(i=1; i<odd.size() && c<n-1; i+=2 )
- {
- cout<<odd[i-1]<<" "<<odd[i]<<endl;
- c++;
- }
- for( i=1; i<even.size() && c<n-1; i+=2)
- {
- cout<<even[i-1]<<" "<<even[i]<<endl;
- c++;
- }
- odd.clear();
- even.clear();
- }
- }
No comments