108122024-04-15 13:20:20CWMSzimmetrikus sorozatcpp11Wrong answer 9/100234ms19860 KiB
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

bool pComp(pair<int, int> a, pair<int, int> b) {
    if (a.first > b.first) return true;
    else if (a.first == b.first) {
        if (a.second > b.second) return true;
        else return false;
    }
    else return false;
}

int main()
{
    int n;
    cin >> n;
    map<int, int> change;
    vector<int> inp(n);
    vector<pair<int, int>> updates;
    for (size_t i = 0; i < n; i++)
    {
        cin >> inp[i];
    }
    for (size_t i = 0; i < n/2; i++)
    {
        int one = inp[i];
        int two = inp[n - i - 1];
        if (change[one] != 0) {
            one = change[one];
        }
        if (change[two] != 0) {
            two = change[two];
        }
        if (one == two) continue;
        else {
            int mx = max(one, two);
            int mn = min(one, two);
            updates.push_back({ mx, mn });
            change[mx] = mn;
        }
    }
    sort(updates.begin(), updates.end(), pComp);
    cout << updates.size() << "\n";
    for (size_t i = 0; i < updates.size(); i++)
    {
        cout << updates[i].first << " " << updates[i].second << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Wrong answer97ms8044 KiB
subtask29/9
3Accepted3ms2256 KiB
4Accepted3ms2588 KiB
5Accepted3ms2744 KiB
6Accepted3ms2824 KiB
7Accepted3ms2944 KiB
subtask30/14
8Accepted3ms3308 KiB
9Accepted3ms3328 KiB
10Wrong answer2ms3368 KiB
11Accepted3ms3308 KiB
12Accepted3ms3328 KiB
13Accepted2ms3408 KiB
subtask40/25
14Wrong answer3ms3412 KiB
15Wrong answer3ms3552 KiB
16Wrong answer4ms3660 KiB
17Wrong answer4ms3852 KiB
18Wrong answer4ms3896 KiB
19Wrong answer4ms3920 KiB
20Wrong answer4ms4172 KiB
21Accepted4ms4148 KiB
subtask50/22
22Accepted140ms15736 KiB
23Accepted153ms16968 KiB
24Accepted170ms16928 KiB
25Accepted150ms16252 KiB
26Wrong answer136ms16136 KiB
27Wrong answer155ms17036 KiB
28Wrong answer158ms17044 KiB
29Wrong answer143ms16480 KiB
30Wrong answer123ms16352 KiB
31Wrong answer135ms17356 KiB
32Wrong answer136ms17296 KiB
33Wrong answer131ms16476 KiB
34Wrong answer123ms16284 KiB
35Wrong answer142ms17208 KiB
36Wrong answer142ms17276 KiB
37Wrong answer126ms16280 KiB
subtask60/30
38Accepted3ms4748 KiB
39Wrong answer97ms10900 KiB
40Accepted3ms2256 KiB
41Accepted3ms2588 KiB
42Accepted3ms2744 KiB
43Accepted3ms2824 KiB
44Accepted3ms2944 KiB
45Accepted3ms3308 KiB
46Accepted3ms3328 KiB
47Wrong answer2ms3368 KiB
48Accepted3ms3308 KiB
49Accepted3ms3328 KiB
50Accepted2ms3408 KiB
51Wrong answer3ms3412 KiB
52Wrong answer3ms3552 KiB
53Wrong answer4ms3660 KiB
54Wrong answer4ms3852 KiB
55Wrong answer4ms3896 KiB
56Wrong answer4ms3920 KiB
57Wrong answer4ms4172 KiB
58Accepted4ms4148 KiB
59Accepted140ms15736 KiB
60Accepted153ms16968 KiB
61Accepted170ms16928 KiB
62Accepted150ms16252 KiB
63Wrong answer136ms16136 KiB
64Wrong answer155ms17036 KiB
65Wrong answer158ms17044 KiB
66Wrong answer143ms16480 KiB
67Wrong answer123ms16352 KiB
68Wrong answer135ms17356 KiB
69Wrong answer136ms17296 KiB
70Wrong answer131ms16476 KiB
71Wrong answer123ms16284 KiB
72Wrong answer142ms17208 KiB
73Wrong answer142ms17276 KiB
74Wrong answer126ms16280 KiB
75Wrong answer210ms19628 KiB
76Wrong answer199ms12548 KiB
77Wrong answer94ms8204 KiB
78Wrong answer203ms12600 KiB
79Wrong answer185ms9708 KiB
80Accepted126ms15056 KiB
81Accepted126ms15064 KiB
82Accepted126ms15064 KiB
83Wrong answer234ms19860 KiB
84Wrong answer115ms8416 KiB
85Wrong answer203ms9968 KiB
86Accepted145ms15664 KiB
87Accepted145ms15796 KiB
88Accepted145ms15792 KiB
89Accepted143ms15920 KiB