Click Here to go back to the homepage.

Eeny Meeny Solution:


#include <bits/stdc++.h>

using namespace std;

std::vector<std::string> string_split(const std::string &s, const string &delimiter=" "){
    std::vector<std::string> tokens;
    std::string token;
    size_t pos = 0, prev = 0, delim_length = delimiter.length();
    while ((pos = s.find(delimiter, pos)) != std::string::npos){
        token = s.substr(prev, pos - prev);
        if(!token.empty()){
            tokens.push_back(token);
        }
        prev = pos += delim_length;
    }
    tokens.push_back(s.substr(prev, pos));
    return tokens;
}

int main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    string line;
    getline(cin, line);
    int words = count(line.begin(), line.end(), ' ');
    getline(cin, line);
    int people = stoi(line);
    vector<string> remaining;
    while(people--){
        getline(cin, line);
        remaining.push_back(line);
    }
    vector<string> t1;
    vector<string> t2;
    bool team1 = true;
    int index = 0;
    while(remaining.size()){
        index += words;
        index %= remaining.size();
        if(team1){
            t1.push_back(remaining[index]);
        } else {
            t2.push_back(remaining[index]);
        }
        team1 = !team1;
        remaining.erase(remaining.begin() + index);
    }
    cout << t1.size() << "\n";
    for(auto it = t1.begin(); it != t1.end(); it++){
        cout << *it << "\n";
    }
    cout << t2.size() << "\n";
    for(auto it = t2.begin(); it != t2.end(); it++){
        cout << *it << "\n";
    }
    
    
    return 0;
}