Advertisement
Dang_Quan_10_Tin

VOTE (HSGHN L9 2020-2021)

Dec 19th, 2021
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. constexpr int N = 5e3 + 5;
  7. int n, b[N];
  8.  
  9. void Read()
  10. {
  11.     cin >> n;
  12.  
  13.     for (int i = 1; i <= n; ++i)
  14.         for (int j = 1; j <= n; ++j)
  15.         {
  16.             char c;
  17.             cin >> c;
  18.  
  19.             if (c == 'X')
  20.                 ++b[j];
  21.         }
  22. }
  23.  
  24. void Solve()
  25. {
  26.     int maxn(0), cnt(0);
  27.  
  28.     for (int i = 1; i <= n; ++i)
  29.         if (maxn < b[i])
  30.         {
  31.             maxn = b[i];
  32.             cnt = 1;
  33.         }
  34.         else if (maxn == b[i])
  35.             ++cnt;
  36.  
  37.     cout << cnt << " " << maxn << "\n";
  38.  
  39.     for (int i = 1; i <= n; ++i)
  40.         if (maxn == b[i])
  41.             cout << i << " ";
  42. }
  43.  
  44. int32_t main()
  45. {
  46.     ios::sync_with_stdio(0);
  47.     cin.tie(0);
  48.     cout.tie(0);
  49.     freopen("VOTE.INP", "r", stdin);
  50.     freopen("VOTE.OUT", "w", stdout);
  51.  
  52.     Read();
  53.     Solve();
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement