INSERTEVEN -Editorial

PROBLEM LINK:

Practice
Contest

Author: rocknot
Tester: root_rvl
Editorialist:rocknot

DIFFICULTY:

EASY

PREREQUISITES:

Implementation

PROBLEM:

Aditya is obsessed with even numbers and consider them lucky. One day he was given task of managing the the database for his company he was given location of important files and he needs to keep them safe. So he decided to store this files in special way for that he needs to remove odd number from his list. In order to do this he decided to increment the value of all the odd integers in the list and insert a copy of that element in that list after that element. You are given list of distinct integers Arr[N] denoting list of location you need to determine the position at which the elements are inserted

EXPLANATION:

You just need to find the position after which element is inserted and last index.

SOLUTIONS:

Solution
#include <bits/stdc++.h>
using namespace std;
int main(){
    int T;
    cin>>T;
    while(T--){
        int N;
        cin>>N;
        vector<int> list;
        for(int i=0;i<N;i++){
            int temp;
            cin>>temp;
            if(temp%2!=0){
                N++;
                i++;
                list.push_back(i+1);
            }
        }
        cout<<N<<endl;
        for(auto it=list.begin();it!=list.end();it++){
            cout<<*it<<" ";
        }
        cout<<endl;
    }
    return 0;
}