109992024-06-02 15:02:17Vkrisztian01Adjacent Pairscpp17Wrong answer 0/100303ms2132 KiB
#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int t,n,a;
pair<int,int>e,f;
vector<int>nums1;
vector<int>nums2;

pair<int,int> kezel1(pair<int,int> p,int x)
{
    if(p.first==x) return p;
    if(p.second==x && nums1[p.first]<nums1[p.second])
    {
        swap(p.first,p.second);
        return p;
    }

    if(nums1[p.first]<nums1[x])
    {
        p.second=p.first;
        p.first=x;
        return p;
    }
    if(nums1[p.second]<nums1[x])
    {
        p.second=x;
        return p;
    }
    return p;
}

pair<int,int> kezel2(pair<int,int> p,int x)
{
    if(p.first==x) return p;
    if(p.second==x && nums2[p.first]<nums2[p.second])
    {
        swap(p.first,p.second);
        return p;
    }
    if(nums2[p.first]<nums2[x])
    {
        p.second=p.first;
        p.first=x;
        return p;
    }
    if(nums2[p.second]<nums2[x])
    {
        p.second=x;
        return p;
    }
    return p;
}

int main()
{
    cin>>t;
    while(t--)
    {
        e=make_pair(0,0);
        f=make_pair(0,0);
        cin>>n;
        nums1.assign(n+1,0);
        nums2.assign(n+1,0);
        for(int i=1;i<=n;i++)
        {
            cin>>a;
            if(i%2) nums1[a]++;
            else nums2[a]++;
            if(i%2) e=kezel1(e,a);
            else f=kezel2(f,a);
        }
    if(e.first==f.first) cout<<min(n-nums1[e.first]-nums2[f.second],n-nums1[e.second]-nums2[f.second])<<endl;
    else cout<<n-nums1[e.first]-nums2[f.first]<<endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
00/0
1Accepted0/02ms356 KiB
10/20
2Wrong answer3ms396 KiB
3Accepted3ms384 KiB
4Wrong answer3ms408 KiB
5Accepted3ms380 KiB
6Accepted2ms256 KiB
7Accepted3ms384 KiB
8Accepted3ms356 KiB
9Accepted2ms376 KiB
10Accepted3ms356 KiB
11Accepted3ms256 KiB
12Accepted3ms372 KiB
13Accepted3ms356 KiB
14Wrong answer2ms376 KiB
15Accepted3ms356 KiB
16Accepted3ms356 KiB
17Wrong answer3ms496 KiB
18Wrong answer2ms504 KiB
19Wrong answer2ms376 KiB
20Wrong answer2ms228 KiB
21Wrong answer2ms228 KiB
22Wrong answer3ms500 KiB
23Accepted3ms512 KiB
24Wrong answer2ms384 KiB
25Wrong answer3ms356 KiB
26Wrong answer2ms376 KiB
27Wrong answer2ms384 KiB
28Wrong answer3ms376 KiB
29Wrong answer3ms300 KiB
30Wrong answer2ms484 KiB
31Wrong answer2ms384 KiB
32Wrong answer2ms256 KiB
33Wrong answer2ms504 KiB
34Wrong answer3ms356 KiB
35Accepted3ms512 KiB
36Wrong answer3ms356 KiB
37Accepted3ms256 KiB
38Accepted3ms384 KiB
39Wrong answer3ms384 KiB
40Accepted3ms384 KiB
41Accepted3ms504 KiB
42Accepted3ms236 KiB
43Accepted4ms352 KiB
44Accepted2ms384 KiB
45Accepted3ms632 KiB
46Accepted2ms376 KiB
47Accepted2ms380 KiB
20/10
48Accepted3ms256 KiB
49Accepted3ms356 KiB
50Accepted3ms356 KiB
51Accepted3ms356 KiB
52Accepted3ms372 KiB
53Accepted3ms356 KiB
54Wrong answer3ms384 KiB
55Wrong answer2ms256 KiB
56Accepted3ms512 KiB
57Accepted3ms256 KiB
58Accepted2ms256 KiB
59Accepted2ms356 KiB
60Wrong answer3ms384 KiB
61Wrong answer3ms500 KiB
62Wrong answer3ms432 KiB
63Wrong answer3ms372 KiB
64Wrong answer3ms356 KiB
65Wrong answer3ms356 KiB
66Wrong answer3ms224 KiB
67Wrong answer3ms356 KiB
68Wrong answer3ms400 KiB
69Wrong answer4ms356 KiB
70Wrong answer3ms392 KiB
71Wrong answer3ms504 KiB
72Wrong answer3ms256 KiB
73Wrong answer3ms228 KiB
74Wrong answer2ms376 KiB
75Wrong answer3ms380 KiB
76Wrong answer2ms228 KiB
77Wrong answer3ms356 KiB
78Accepted3ms356 KiB
79Wrong answer3ms376 KiB
80Accepted3ms288 KiB
81Wrong answer3ms504 KiB
82Wrong answer2ms256 KiB
83Accepted3ms256 KiB
84Accepted3ms356 KiB
85Wrong answer3ms236 KiB
86Accepted2ms376 KiB
87Accepted3ms256 KiB
88Accepted2ms228 KiB
89Accepted3ms400 KiB
90Accepted2ms504 KiB
30/25
91Accepted4ms536 KiB
92Accepted4ms420 KiB
93Accepted4ms356 KiB
94Accepted4ms512 KiB
95Accepted3ms376 KiB
96Accepted4ms228 KiB
97Wrong answer4ms356 KiB
98Wrong answer4ms384 KiB
99Wrong answer3ms356 KiB
100Wrong answer3ms360 KiB
101Accepted4ms356 KiB
102Accepted4ms504 KiB
103Wrong answer4ms356 KiB
104Wrong answer4ms380 KiB
105Wrong answer3ms376 KiB
106Wrong answer3ms356 KiB
107Wrong answer4ms356 KiB
108Wrong answer4ms356 KiB
109Wrong answer4ms420 KiB
110Wrong answer4ms376 KiB
111Wrong answer4ms356 KiB
112Wrong answer4ms376 KiB
113Wrong answer4ms632 KiB
114Wrong answer4ms356 KiB
115Wrong answer4ms228 KiB
116Wrong answer4ms356 KiB
117Wrong answer4ms476 KiB
118Wrong answer4ms516 KiB
119Wrong answer4ms356 KiB
120Wrong answer4ms228 KiB
121Wrong answer4ms356 KiB
122Wrong answer4ms412 KiB
123Accepted3ms360 KiB
124Wrong answer3ms256 KiB
125Accepted4ms392 KiB
126Accepted4ms484 KiB
127Accepted8ms416 KiB
128Wrong answer4ms296 KiB
129Wrong answer4ms228 KiB
130Accepted4ms228 KiB
131Accepted4ms364 KiB
132Accepted4ms228 KiB
40/45
133Accepted4ms356 KiB
134Accepted97ms556 KiB
135Accepted76ms492 KiB
136Accepted61ms500 KiB
137Accepted54ms356 KiB
138Accepted71ms928 KiB
139Accepted79ms1912 KiB
140Wrong answer103ms376 KiB
141Wrong answer87ms356 KiB
142Wrong answer57ms356 KiB
143Wrong answer56ms488 KiB
144Accepted71ms1060 KiB
145Accepted76ms1912 KiB
146Wrong answer103ms484 KiB
147Wrong answer76ms504 KiB
148Wrong answer64ms356 KiB
149Wrong answer54ms356 KiB
150Wrong answer71ms740 KiB
151Wrong answer79ms1928 KiB
152Wrong answer101ms504 KiB
153Wrong answer78ms488 KiB
154Wrong answer59ms504 KiB
155Wrong answer54ms356 KiB
156Wrong answer71ms1100 KiB
157Wrong answer78ms2032 KiB
158Wrong answer101ms356 KiB
159Wrong answer79ms420 KiB
160Wrong answer61ms500 KiB
161Wrong answer56ms376 KiB
162Wrong answer71ms1032 KiB
163Wrong answer78ms2132 KiB
164Wrong answer98ms532 KiB
165Wrong answer75ms356 KiB
166Wrong answer57ms356 KiB
167Wrong answer54ms356 KiB
168Accepted71ms996 KiB
169Accepted78ms2040 KiB
170Accepted303ms764 KiB
171Wrong answer109ms352 KiB
172Wrong answer82ms632 KiB
173Wrong answer61ms504 KiB
174Accepted54ms504 KiB
175Accepted71ms740 KiB
176Accepted78ms1892 KiB
177Accepted76ms1896 KiB
178Accepted78ms2020 KiB
179Accepted75ms1892 KiB
180Accepted76ms1892 KiB
181Accepted76ms1892 KiB
182Accepted76ms2020 KiB
183Accepted76ms1892 KiB
184Accepted78ms1888 KiB
185Accepted79ms1912 KiB
186Wrong answer76ms2024 KiB