171992025-06-03 11:30:54ercseferencSzimmetrikus sorozatcpp17Wrong answer 0/100586ms131072 KiB
#include <bits/stdc++.h>
using namespace std;
struct par{int a,b;};
struct adatszam{int ert,ind,csop;};
bool has1(adatszam m, adatszam n){
    return m.ert<n.ert;}
bool has2(adatszam m, adatszam n){
    return m.ind<n.ind;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); vector<par>b;
    int n,x,y; cin>>n;
    vector<adatszam>a(n);
    for(int i=0; i<n; i++){cin>>a[i].ert; a[i].ind=i;}
    vector<vector<int> >csoportok; int t=0;
    sort(a.begin(),a.end(), has1);
    vector<int>ures; csoportok.push_back(ures);
   for(int i=0; i<n; i++){
        csoportok[t].push_back(a[i].ind);
        a[i].csop=t;
        if(a[i].ert!=a[i+1].ert && i!=n-1){t++;
        csoportok.push_back(ures);}}
    /*for(int i=0; i<csoportok.size(); i++){
        for(int j=0; j<csoportok[i].size(); j++)cout<<csoportok[i][j]<<" ";
        cout<<endl;}*/
    sort(a.begin(),a.end(), has2);
    //for(int i=0; i<n; i++)cout<<a[i].ert<<" ";
    for(int i=0; i<n/2; i++){
        if(a[i].ert!=a[n-i-1].ert){
            if(a[i].ert>a[n-i-1].ert){
                x=n-i-1, y=i;}
            else {x=i; y=n-i-1;}
            par q; q.a=a[y].ert; q.b=a[x].ert; b.push_back(q);
            int v=csoportok[a[y].csop].size();
            for(int j=0; j<v; j++){
                csoportok[a[x].csop].push_back(csoportok[a[y].csop][j]);
                a[csoportok[a[y].csop][j]].ert=a[x].ert;
                a[csoportok[a[y].csop][j]].csop=a[x].csop;}}}
    cout<<b.size()<<endl;
    for(int i=0; i<b.size(); i++)cout<<b[i].a<<" "<<b[i].b<<endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Wrong answer122ms6632 KiB
subtask20/9
3Wrong answer2ms748 KiB
4Accepted2ms316 KiB
5Wrong answer2ms316 KiB
6Accepted2ms316 KiB
7Wrong answer2ms564 KiB
subtask30/14
8Wrong answer1ms512 KiB
9Accepted1ms316 KiB
10Wrong answer1ms316 KiB
11Accepted1ms316 KiB
12Wrong answer1ms344 KiB
13Accepted1ms316 KiB
subtask40/25
14Wrong answer1ms316 KiB
15Wrong answer2ms316 KiB
16Wrong answer4ms748 KiB
17Wrong answer4ms648 KiB
18Wrong answer4ms564 KiB
19Wrong answer9ms3272 KiB
20Wrong answer18ms6628 KiB
21Accepted2ms500 KiB
subtask50/22
22Wrong answer217ms10716 KiB
23Runtime error586ms131072 KiB
24Wrong answer268ms11228 KiB
25Wrong answer226ms10720 KiB
26Wrong answer211ms10888 KiB
27Runtime error573ms131072 KiB
28Wrong answer254ms11260 KiB
29Wrong answer219ms10852 KiB
30Wrong answer207ms10720 KiB
31Runtime error541ms131072 KiB
32Wrong answer252ms11232 KiB
33Wrong answer224ms10884 KiB
34Wrong answer200ms10720 KiB
35Wrong answer500ms80004 KiB
36Wrong answer248ms11232 KiB
37Wrong answer221ms10720 KiB
subtask60/30
38Accepted1ms316 KiB
39Wrong answer125ms6632 KiB
40Wrong answer2ms748 KiB
41Accepted2ms316 KiB
42Wrong answer2ms316 KiB
43Accepted2ms316 KiB
44Wrong answer2ms564 KiB
45Wrong answer1ms512 KiB
46Accepted1ms316 KiB
47Wrong answer1ms316 KiB
48Accepted1ms316 KiB
49Wrong answer1ms344 KiB
50Accepted1ms316 KiB
51Wrong answer1ms316 KiB
52Wrong answer2ms316 KiB
53Wrong answer4ms748 KiB
54Wrong answer4ms648 KiB
55Wrong answer4ms564 KiB
56Wrong answer9ms3272 KiB
57Wrong answer18ms6628 KiB
58Accepted2ms500 KiB
59Wrong answer217ms10716 KiB
60Runtime error586ms131072 KiB
61Wrong answer268ms11228 KiB
62Wrong answer226ms10720 KiB
63Wrong answer211ms10888 KiB
64Runtime error573ms131072 KiB
65Wrong answer254ms11260 KiB
66Wrong answer219ms10852 KiB
67Wrong answer207ms10720 KiB
68Runtime error541ms131072 KiB
69Wrong answer252ms11232 KiB
70Wrong answer224ms10884 KiB
71Wrong answer200ms10720 KiB
72Wrong answer500ms80004 KiB
73Wrong answer248ms11232 KiB
74Wrong answer221ms10720 KiB
75Wrong answer286ms13272 KiB
76Runtime error418ms131072 KiB
77Wrong answer93ms6192 KiB
78Runtime error435ms131072 KiB
79Runtime error370ms131072 KiB
80Accepted93ms7912 KiB
81Accepted94ms7912 KiB
82Accepted94ms8104 KiB
83Wrong answer286ms14200 KiB
84Wrong answer97ms6060 KiB
85Runtime error441ms131072 KiB
86Accepted101ms8160 KiB
87Accepted100ms8160 KiB
88Accepted101ms8156 KiB
89Accepted101ms8160 KiB