Advertisement
myloyo

j задача set/map

Jul 9th, 2023
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <algorithm>
  6. #include <set>
  7. #include <list>
  8. #include <sstream>
  9. #include <vector>
  10. #include <map>
  11. #include <stdlib.h>
  12.  
  13. using namespace std;
  14. ifstream in("input.txt");
  15. ofstream out("output.txt");
  16.  
  17. int main() {
  18.     map <string, string> m;
  19.     string x, y;
  20.     int n; cin >> n;
  21.     for (int i = 0; i < n; i++) {
  22.         cin >> x;
  23.         if (m.find(x)  == m.end()) {
  24.             m[x] = "OK";
  25.         }
  26.         else {
  27.             y = x + to_string(m.count(x));
  28.             auto it = m.end();
  29.             m[y] = x + to_string(m.count(x));
  30.         }
  31.     }
  32.  
  33.     for (auto x : m) {
  34.         cout << x.first << endl;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement