// password.cpp : Defines the entry point for the console application. // #include #include #include using namespace std; int main(int argc, char* argv[]) { int N; string str; str.reserve(100000); fstream fin, fout; fin.open("password.in", ios_base::in); fin >> N; fin >> str; fout.open("password.out", ios_base::out); if (N == 1) { fout << 1 << endl; fout << str << endl; } else { vector passwords; passwords.reserve(100000); int max = 1, last = 1; for (int i = 1; i < N; i++) { if (str[i] == str[i - 1]) { max++; } else { if (max > last) { passwords.clear(); last = max; } if (max == last) { passwords.push_back(str.substr(i - max, max)); last = max; } max = 1; } } if (max > last) { passwords.clear(); last = max; } if (max == last) { passwords.push_back(str.substr(N - max, max)); last = max; } fout << passwords.size() << endl; for (int i = 0; i < passwords.size(); i++) fout << passwords[i] << endl; } return 0; }