Advertisement
kolioi

Untitled

Dec 12th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. //100/100
  2. //Memory: 14.89 MB Time : 1.570 s
  3. #include <iostream>
  4. #include <string>
  5. #include <unordered_map>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     const int dnaLength = 5;
  12.     string input;
  13.     input.reserve(20971203);
  14.     getline(cin, input);
  15.  
  16.     unordered_map<string, int> counts;
  17.     string currentDNA;
  18.     for (size_t i = 0, currentIndex = 0; i < input.size() / dnaLength; i++, currentIndex += dnaLength)
  19.     {
  20.         currentDNA = input.substr(currentIndex, dnaLength);
  21.         if (++counts[currentDNA] > 1)
  22.             counts.erase(currentDNA);
  23.     }
  24.  
  25.     cout << counts.begin()->first << endl;
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement