Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve()
  5. {
  6.     vector <pair<string, unordered_set <string>>> tap = {
  7.         {"be",{}},
  8.         {"de",{}},
  9.         {"en",{}},
  10.         {"fr",{}},
  11.         {"hy",{}},
  12.         {"it",{}},
  13.         {"ka",{}},
  14.         {"ru",{}},
  15.         {"sv",{}},
  16.         {"uk",{}},
  17.     };
  18.  
  19.     ifstream fin;
  20.  
  21.     for (int i = 0; i < 10; ++i)
  22.     {
  23.        string direct = "D:/Everything_for_your_code/Programs/MOSH/C/C-training-set/";
  24.        direct += tap[i].first + '/';
  25.        for (int c = 1; c <= 100; ++c){
  26.            string path = direct;
  27.            string add = to_string(c);
  28.            path += add + ".txt";
  29.            fin.open(path);
  30.            string a;
  31.            while (fin >> a){
  32.                tap[i].second.insert(a);
  33.            }
  34.            fin.close();
  35.        }
  36.     }
  37.  
  38.     ofstream fout("D:/Everything_for_your_code/Programs/MOSH/C/answer2.txt");
  39.  
  40.     string direct = "D:/Everything_for_your_code/Programs/MOSH/C/C2/";
  41.     for (int i = 1; i <= 1000; ++i){
  42.         string path = direct;
  43.         string add = to_string(i);
  44.         path += add + ".txt";
  45.         fin.open(path);
  46.  
  47.         map <string, int> answer;
  48.  
  49.         string a;
  50.         while (fin >> a){
  51.             for (int q = 0; q < 10; ++q){
  52.                 if (tap[q].second.find(a) != tap[q].second.end()){
  53.                     answer[tap[q].first]++;
  54.                 }
  55.             }
  56.         }
  57.         fin.close();
  58.  
  59.         long long ans = 0;
  60.         string ans_;
  61.  
  62.         for (auto q: answer){
  63.             if (q.second > ans){
  64.                 ans = q.second;
  65.                 ans_ = q.first;
  66.             }
  67.         }
  68.  
  69.         fout << ans_ << endl;
  70.     }
  71.  
  72.     cout << "Good bye!!!";
  73. }
  74.  
  75. int main()
  76. {
  77.     ios_base :: sync_with_stdio(false);
  78.     cin.tie(0);
  79.     cout.tie(0);
  80.  
  81.     try{
  82.         solve();
  83.     } catch (...){
  84.         cout << "Compile error";
  85.     }
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement