fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <map>
  4. #include <set>
  5. #include <cmath>
  6. #include <vector>
  7. #include <climits>
  8. #include <string>
  9. #include <algorithm>
  10. #include <sstream>
  11. using namespace std;
  12.  
  13. vector<string> split(string haystack, string needle) {
  14. vector<string> result;
  15. int startPos = 0;
  16. int foundPos = haystack.find(needle, startPos);
  17. while (foundPos != string::npos) {
  18. int count = foundPos - startPos;
  19. string token = haystack.substr(startPos, count);
  20. if (!token.empty()) {
  21. result.push_back(token);
  22. }
  23. startPos = foundPos + needle.length();
  24. foundPos = haystack.find(needle, startPos);
  25. }
  26. string token = haystack.substr(startPos, haystack.length() - startPos);
  27. if (!token.empty()) {
  28. result.push_back(token);
  29. }
  30. return result;
  31. }
  32.  
  33. string nameConvert(const string& name) {
  34. const string DELIMITER = " ";
  35. stringstream builder;
  36. auto parts = split(name, DELIMITER);
  37. for (auto part : parts) {
  38. part[0] = toupper(part[0]);
  39. transform(part.begin() + 1, part.end(), part.begin() + 1, ::tolower);
  40. builder << part << DELIMITER;
  41. }
  42. return builder.str();
  43. }
  44.  
  45. string dateConvert(const string& date) {
  46. const string DELIMITER = "/";
  47. stringstream builder;
  48. auto parts = split(date, DELIMITER);
  49. builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
  50. builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
  51. builder << parts[2];
  52. return builder.str();
  53. }
  54.  
  55. map<string, int> mp;
  56. string email(string name) {
  57. transform(name.begin(), name.end(), name.begin(), ::tolower);
  58. stringstream builder;
  59. auto parts = split(name, " ");
  60. builder << parts.back();
  61. for (int i = 0;i < parts.size() - 1;i++) {
  62. builder << parts[i][0];
  63. }
  64. string tmp = builder.str();
  65. mp[tmp]++;
  66. if (mp[tmp] > 1) {
  67. builder << mp[tmp];
  68. }
  69. builder << "@xyz.edu.vn";
  70. return builder.str();
  71. }
  72.  
  73. string password(string date) {
  74. auto parts = split(date, "/");
  75. stringstream builder;
  76. for (auto part : parts) {
  77. builder << stoi(part);
  78. }
  79. return builder.str();
  80. }
  81.  
  82. int main() {
  83. ios_base::sync_with_stdio(false);
  84. cin.tie(NULL);
  85.  
  86. int query;cin >> query;
  87. cin.ignore();
  88. for (int i = 0;i < query;i++) {
  89. string line;getline(cin, line);
  90. auto parts = split(line, " ");
  91. string dob = parts.back();
  92. stringstream builder;
  93. for (int i = 0;i < parts.size() - 1;i++) {
  94. builder << parts[i] << " ";
  95. }
  96. string name = builder.str();
  97. cout << email(name) << " " << password(dob) << endl;
  98. }
  99. return 0;
  100. }
  101.  
  102.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty