-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1389C.cpp
More file actions
24 lines (21 loc) · 705 Bytes
/
1389C.cpp
File metadata and controls
24 lines (21 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "bits/stdc++.h"
using namespace std;
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int t = 1; cin >> t; while (t--) {
string s; cin >> s;
int n = (int) s.size();
if(n <= 2) {cout << "0\n"; continue;}
int ans = 0;
for(char c = '0'; c <= '9'; ++c) for(char d = '0'; d <= '9'; ++d) {
int temp = 0, check = 0;
for(auto& i : s) if((check && (i == c)) || (!check && (i == d))) {
temp++;
check = 1 - check;
}
temp -= bool(temp % 2 && c != d);
ans = max(ans, temp);
}
cout << n - ans << "\n";
}
}