10812 | 2024-04-15 13:20:20 | CWM | Szimmetrikus sorozat | cpp11 | Wrong answer 9/100 | 234ms | 19860 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";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Wrong answer | 97ms | 8044 KiB | ||||
subtask2 | 9/9 | ||||||
3 | Accepted | 3ms | 2256 KiB | ||||
4 | Accepted | 3ms | 2588 KiB | ||||
5 | Accepted | 3ms | 2744 KiB | ||||
6 | Accepted | 3ms | 2824 KiB | ||||
7 | Accepted | 3ms | 2944 KiB | ||||
subtask3 | 0/14 | ||||||
8 | Accepted | 3ms | 3308 KiB | ||||
9 | Accepted | 3ms | 3328 KiB | ||||
10 | Wrong answer | 2ms | 3368 KiB | ||||
11 | Accepted | 3ms | 3308 KiB | ||||
12 | Accepted | 3ms | 3328 KiB | ||||
13 | Accepted | 2ms | 3408 KiB | ||||
subtask4 | 0/25 | ||||||
14 | Wrong answer | 3ms | 3412 KiB | ||||
15 | Wrong answer | 3ms | 3552 KiB | ||||
16 | Wrong answer | 4ms | 3660 KiB | ||||
17 | Wrong answer | 4ms | 3852 KiB | ||||
18 | Wrong answer | 4ms | 3896 KiB | ||||
19 | Wrong answer | 4ms | 3920 KiB | ||||
20 | Wrong answer | 4ms | 4172 KiB | ||||
21 | Accepted | 4ms | 4148 KiB | ||||
subtask5 | 0/22 | ||||||
22 | Accepted | 140ms | 15736 KiB | ||||
23 | Accepted | 153ms | 16968 KiB | ||||
24 | Accepted | 170ms | 16928 KiB | ||||
25 | Accepted | 150ms | 16252 KiB | ||||
26 | Wrong answer | 136ms | 16136 KiB | ||||
27 | Wrong answer | 155ms | 17036 KiB | ||||
28 | Wrong answer | 158ms | 17044 KiB | ||||
29 | Wrong answer | 143ms | 16480 KiB | ||||
30 | Wrong answer | 123ms | 16352 KiB | ||||
31 | Wrong answer | 135ms | 17356 KiB | ||||
32 | Wrong answer | 136ms | 17296 KiB | ||||
33 | Wrong answer | 131ms | 16476 KiB | ||||
34 | Wrong answer | 123ms | 16284 KiB | ||||
35 | Wrong answer | 142ms | 17208 KiB | ||||
36 | Wrong answer | 142ms | 17276 KiB | ||||
37 | Wrong answer | 126ms | 16280 KiB | ||||
subtask6 | 0/30 | ||||||
38 | Accepted | 3ms | 4748 KiB | ||||
39 | Wrong answer | 97ms | 10900 KiB | ||||
40 | Accepted | 3ms | 2256 KiB | ||||
41 | Accepted | 3ms | 2588 KiB | ||||
42 | Accepted | 3ms | 2744 KiB | ||||
43 | Accepted | 3ms | 2824 KiB | ||||
44 | Accepted | 3ms | 2944 KiB | ||||
45 | Accepted | 3ms | 3308 KiB | ||||
46 | Accepted | 3ms | 3328 KiB | ||||
47 | Wrong answer | 2ms | 3368 KiB | ||||
48 | Accepted | 3ms | 3308 KiB | ||||
49 | Accepted | 3ms | 3328 KiB | ||||
50 | Accepted | 2ms | 3408 KiB | ||||
51 | Wrong answer | 3ms | 3412 KiB | ||||
52 | Wrong answer | 3ms | 3552 KiB | ||||
53 | Wrong answer | 4ms | 3660 KiB | ||||
54 | Wrong answer | 4ms | 3852 KiB | ||||
55 | Wrong answer | 4ms | 3896 KiB | ||||
56 | Wrong answer | 4ms | 3920 KiB | ||||
57 | Wrong answer | 4ms | 4172 KiB | ||||
58 | Accepted | 4ms | 4148 KiB | ||||
59 | Accepted | 140ms | 15736 KiB | ||||
60 | Accepted | 153ms | 16968 KiB | ||||
61 | Accepted | 170ms | 16928 KiB | ||||
62 | Accepted | 150ms | 16252 KiB | ||||
63 | Wrong answer | 136ms | 16136 KiB | ||||
64 | Wrong answer | 155ms | 17036 KiB | ||||
65 | Wrong answer | 158ms | 17044 KiB | ||||
66 | Wrong answer | 143ms | 16480 KiB | ||||
67 | Wrong answer | 123ms | 16352 KiB | ||||
68 | Wrong answer | 135ms | 17356 KiB | ||||
69 | Wrong answer | 136ms | 17296 KiB | ||||
70 | Wrong answer | 131ms | 16476 KiB | ||||
71 | Wrong answer | 123ms | 16284 KiB | ||||
72 | Wrong answer | 142ms | 17208 KiB | ||||
73 | Wrong answer | 142ms | 17276 KiB | ||||
74 | Wrong answer | 126ms | 16280 KiB | ||||
75 | Wrong answer | 210ms | 19628 KiB | ||||
76 | Wrong answer | 199ms | 12548 KiB | ||||
77 | Wrong answer | 94ms | 8204 KiB | ||||
78 | Wrong answer | 203ms | 12600 KiB | ||||
79 | Wrong answer | 185ms | 9708 KiB | ||||
80 | Accepted | 126ms | 15056 KiB | ||||
81 | Accepted | 126ms | 15064 KiB | ||||
82 | Accepted | 126ms | 15064 KiB | ||||
83 | Wrong answer | 234ms | 19860 KiB | ||||
84 | Wrong answer | 115ms | 8416 KiB | ||||
85 | Wrong answer | 203ms | 9968 KiB | ||||
86 | Accepted | 145ms | 15664 KiB | ||||
87 | Accepted | 145ms | 15796 KiB | ||||
88 | Accepted | 145ms | 15792 KiB | ||||
89 | Accepted | 143ms | 15920 KiB |