7oSkaaa

Vent System

Aug 8th, 2021 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define cin(vec) for(auto& i : vec) cin >> i
  5. #define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
  6. #define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
  7. #define cout_2d(vec, n, m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] << " "; j++);
  8. #define cout_map(mp) for(auto& [f, s] : mp) cout << f << "  " << s << "\n";
  9. #define fixed(n) cout << fixed << setprecision(n)
  10. #define Ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  11. #define fill(vec, value) memset(vec, value, sizeof(vec));
  12. #define Num_of_Digits(n) ((int)log10(n)+1)
  13. #define all(vec) vec.begin(),vec.end()
  14. #define rall(vec) vec.rbegin(),vec.rend()
  15. #define sz(x) int(x.size())
  16. #define fi first
  17. #define se second
  18. #define Pair pair < int, int >
  19. #define ll long long
  20. #define ull unsigned long long
  21. #define Mod  1'000'000'007
  22. #define INF 2'000'000'000
  23. #define all(vec) vec.begin(),vec.end()
  24. #define rall(vec) vec.rbegin(),vec.rend()
  25. #define sz(x) int(x.size())
  26. #define fi first
  27. #define se second
  28. #define Pair pair < int, int >
  29. #define ll long long
  30. #define ull unsigned long long
  31. #define Mod  1'000'000'007
  32. #define INF 2'000'000'000
  33. #define PI acos(-1)
  34.  
  35. void Code_Crush(){
  36.   ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  37.   #ifndef ONLINE_JUDGE
  38.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  39.   #endif
  40. }
  41.  
  42. int main(){
  43.   Code_Crush();
  44.     int n, m, count;
  45.     cin >> n;
  46.     string room, name, dead, sus_room;
  47.     for(int i = 0; i < n && cin >> room; i++);
  48.     cin >> m;
  49.     vector < pair < string, string > > vent(m);
  50.     for(auto& [f, s] : vent) cin >> f >> s;
  51.     cin >> count;
  52.     int reports = count - 3;
  53.     map < string, int > sus;
  54.     for(int i = 0; i < count && cin >> name; i++)sus[name];
  55.     while(reports--){
  56.         cin >> dead >> room;
  57.         sus.erase(dead);
  58.         count--;
  59.         for(int i = 0; i < count; i++){
  60.             cin >> name >> sus_room;
  61.             bool is_sus = (room == sus_room);
  62.             for(auto & [f, s] : vent)
  63.                 if((f == sus_room && s == room) || (f == room && s == sus_room)) is_sus = true;
  64.             if(is_sus) sus[name]++;
  65.         }
  66.     }
  67.     int mx_cnt = -1;
  68.     for(auto & [f, s] : sus){
  69.         if(s > mx_cnt) name = f, mx_cnt = s;
  70.         else if(s == mx_cnt) name = "?";
  71.     }
  72.     cout << name << "\n";
  73.   return 0;
  74. }
Add Comment
Please, Sign In to add comment