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++:

    1. #include<bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. int t,n,i,a,c,j;
    6. cin>>t;
    7. while(t--)
    8. {
    9. c=0;
    10. vector<int>odd,even;
    11. cin>>n;
    12. for(i=1; i<=2*n; i++)
    13. {
    14. cin>>a;
    15. if(a%2==0)
    16. even.push_back(i);
    17. else
    18. odd.push_back(i);
    19. }
    20. for(i=1; i<odd.size() && c<n-1; i+=2 )
    21. {
    22. cout<<odd[i-1]<<" "<<odd[i]<<endl;
    23. c++;
    24. }
    25. for( i=1; i<even.size() && c<n-1; i+=2)
    26. {
    27. cout<<even[i-1]<<" "<<even[i]<<endl;
    28. c++;
    29. }
    30. odd.clear();
    31. even.clear();
    32. }
    33. }

    No comments

    Most View Post

    Recent post

    Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

        Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

    Powered by Blogger.