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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

    Powered by Blogger.