Created
March 23, 2023 17:37
-
-
Save qjatn0120/628133f279070d14f6c43f106546c307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
#include "debug.h" | |
#endif // DEBUG | |
#ifndef DEBUG | |
template <typename T> | |
void debug(T &x){} | |
template <typename T> | |
void debug(T &x, int i, int j){} | |
#endif // DEBUG | |
#include <bits/stdc++.h> | |
using namespace std; | |
bool allSame(string &s){ | |
for(char c : s){ | |
if(c != s[0]) return false; | |
} | |
return true; | |
} | |
bool threeSame(string &s){ | |
if(s[0] == s[1] && s[1] == s[2]) return true; | |
if(s[1] == s[2] && s[2] == s[3]) return true; | |
return false; | |
} | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
int T; | |
cin >> T; | |
while(T--){ | |
string s; | |
cin >> s; | |
sort(s.begin(), s.end()); | |
if(allSame(s)) cout << "-1\n"; | |
else if(threeSame(s)) cout << "6\n"; | |
else cout << "4\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment