Advertisement
deushiro

Untitled

Nov 30th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, m, p;
  6. vector<pair<pair<int, int>, string>> a;
  7. vector<pair<pair<int, int>, string>> b;
  8.  
  9. void sum(){
  10.     for(int i = 0; i < p; ++i){
  11.         a[n / 2 - 1 - i].first.first++;
  12.         b[n / 2 - 1 - i].first.first++;
  13.     }
  14. }
  15.  
  16. void ans(){
  17.     for(int i = 0; i < p; ++i){
  18.         cout << a[n / 2 - 1 - i].second << " ";
  19.     }
  20.     for(int i = 0; i < p; ++i){
  21.         cout << b[n / 2 - 1 - i].second << " ";
  22.     }
  23. }
  24.  
  25. int main() {
  26.     ios_base::sync_with_stdio(false);
  27.     cin.tie(0);
  28.     cout.tie(0);
  29.     cin >> n >> m >> p;
  30.     for(int i = 0; i < n; ++i){
  31.         string s;
  32.         cin >> s;
  33.         if(i % 2 == 0){
  34.             a.push_back({{0, i / 2}, s});
  35.         }
  36.         else{
  37.             b.push_back({{0, i / 2}, s});
  38.         }
  39.     }
  40.     for(int i = 0; i < m; ++i){
  41.         sum();
  42.         sort(a.begin(), a.begin() + n / 2 - p);
  43.         sort(a.begin() + n / 2 - p, a.end());
  44.         sort(b.begin(), b.begin() + n / 2 - p);
  45.         sort(b.begin() + n / 2 - p, b.end());
  46.         a[0], a.back() = a.back(), a[0];
  47.         b[0], b.back() = b.back(), b[0];
  48.         ans();
  49.         cout << endl;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement