#include #include #include #include #include #include using namespace std; map indexCounts; set orphanFiles; void readIndices(istream& in) { string line = "*"; getline(in, line); while (line != "") { indexCounts[line] = 0; getline (in, line); } } string extractIndex(string fileSpec) { unsigned pos1 = fileSpec.find_last_of('_'); unsigned pos2 = fileSpec.find_last_of('_', pos1-1); string result = fileSpec.substr(0, pos2); // cerr << "Index of " << fileSpec << " is " << result << endl; return result; } void readFiles(istream& in) { string line = "*"; getline(in, line); while (in.good()) { string index = extractIndex(line); if (indexCounts.find(index) != indexCounts.end()) { indexCounts[index] = indexCounts[index] + 1; } else { orphanFiles.insert(line); } getline (in, line); } } void solve (istream& in) { readIndices(in); readFiles(in); bool orphans = false; for (string file: orphanFiles) { cout << "F " << file << endl; orphans = true; } for (auto index: indexCounts) { string name = index.first; int count = index.second; if (count == 0) { cout << "I " << name << endl; orphans = true; } } if (!orphans) cout << "No mismatches." << endl; } int main (int argc, char** argv) { if (argc > 1) { ifstream in (argv[1]); solve (in); } else solve (cin); }