I'm not real sure what your question is. Are you trying to separate the names as you input them? Separating them is the easy part.
The hard part is managing the data after the input. I think you could do something with nested loops and a vector of strings.
Keeping in mind that the extraction operator interrupts the stream at any whitespace (which a space is) you should be able to use the first inner loop to get your input and store it into a vector. You would then use a second inner loop to process the information and set up your maps and sets.
The outer loop would be a main application loop used for "do again" type things.
visual aids help:
// some declarations
char addAnother = 'y';
string name;
string nextName;
vector<string> inNames;
// outer loop
while (addAnother = 'y') {
//inner loop 1, used for input
while (cin >> nextName) {
inNames.push_back(nextName);
// other required actions
}
// inner loop 2, used for processing and storing
// while (...) or for (...) depending on previous code structure and preferences
// prompt for addAnother
} // close outer loop
Someone else may have a better idea, but given my limited abilities, this is how I would do it.