QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#251929#5422. Perfect PalindromeSarwar82WA 27ms3668kbC++201.2kb2023-11-15 13:11:012023-11-15 13:11:02

Judging History

你现在查看的是最新测评结果

  • [2023-11-15 13:11:02]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3668kb
  • [2023-11-15 13:11:01]
  • 提交

answer

/*If we keep holding onto yesterday, what are we going to be tomorrow?*/


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int 
bool debugg = false;
#define dbg if(debugg)
#define F first 
#define S second 
template <typename T>
using order_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());  

int f(string &s)
{
    int n = s.size() , mx = 0;
    map<char,int>cnt;
    for(int i = 0 ; i < n ; i ++){
        cnt[s[i]] ++;
        mx = max(mx , cnt[s[i]]);
    }

    return n - mx;
}

void solve()
{
    string s;
    cin >> s;

    int n = s.size();
    if(n % 2 == 0){
        cout << f(s) << '\n';
    }

    else{
        string a , b;
        for(int i = 0 ; i < n ; i ++){
            if(i % 2) a += s[i];
            else b += s[i];
        }

        cout << min(f(s) , f(a) + f(b)) << '\n';
    }
}



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
        
    int t  = 1;
    cin >> t;
    
    while(t--){
        solve();
    }

    return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3520kb

input:

2
abcb
xxx

output:

2
0

result:

ok 2 number(s): "2 0"

Test #2:

score: -100
Wrong Answer
time: 27ms
memory: 3668kb

input:

11107
lfpbavjsm
pdtlkfwn
fmb
hptdswsoul
bhyjhp
pscfliuqn
nej
nxolzbd
z
clzb
zqomviosz
u
ek
vco
oymonrq
rjd
ktsqti
mdcvserv
x
birnpfu
gsgk
ftchwlm
bzqgar
ovj
nsgiegk
dbolme
nvr
rpsc
fprodu
eqtidwto
j
qty
o
jknssmabwl
qjfv
wrd
aa
ejsf
i
npmmhkef
dzvyon
p
zww
dp
ru
qmwm
sc
wnnjyoepxo
hc
opvfepiko
inuxx...

output:

7
7
1
8
4
7
1
5
0
3
6
0
1
1
5
1
4
6
0
5
2
5
5
1
5
5
1
3
5
6
0
1
0
8
3
1
0
3
0
6
5
0
1
1
1
2
1
8
1
5
4
3
3
4
1
8
5
5
8
7
5
3
0
1
3
1
1
5
0
0
9
3
3
4
8
4
0
4
1
5
5
0
7
6
3
3
9
3
4
1
5
7
8
7
5
1
4
3
1
6
2
7
6
3
3
8
7
8
3
9
3
8
0
5
7
1
6
0
0
5
4
0
7
4
3
2
1
6
7
4
1
4
4
6
3
3
1
5
3
8
5
0
3
5
1
1
3
0
4
7
...

result:

wrong answer 1st numbers differ - expected: '8', found: '7'