Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, m, p;
- vector<pair<pair<int, int>, string>> a;
- vector<pair<pair<int, int>, string>> b;
- void sum(){
- for(int i = 0; i < p; ++i){
- a[n / 2 - 1 - i].first.first++;
- b[n / 2 - 1 - i].first.first++;
- }
- }
- void ans(){
- for(int i = 0; i < p; ++i){
- cout << a[n / 2 - 1 - i].second << " ";
- }
- for(int i = 0; i < p; ++i){
- cout << b[n / 2 - 1 - i].second << " ";
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- cin >> n >> m >> p;
- for(int i = 0; i < n; ++i){
- string s;
- cin >> s;
- if(i % 2 == 0){
- a.push_back({{0, i / 2}, s});
- }
- else{
- b.push_back({{0, i / 2}, s});
- }
- }
- for(int i = 0; i < m; ++i){
- sum();
- sort(a.begin(), a.begin() + n / 2 - p);
- sort(a.begin() + n / 2 - p, a.end());
- sort(b.begin(), b.begin() + n / 2 - p);
- sort(b.begin() + n / 2 - p, b.end());
- a[0], a.back() = a.back(), a[0];
- b[0], b.back() = b.back(), b[0];
- ans();
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement