Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <vector>
- #include <algorithm>
- #define pb push_back
- using namespace std;
- int f(string s)
- {
- set <char> all;
- vector <char> v;
- for (int i = 0; i < 4; ++i) {
- char k = s[i];
- all.insert(k);
- v.pb(k);
- }
- if (all.size() == 1) {
- return -1;
- }
- if (all.size() == 2) {
- int x = count(v.begin(), v.end(), v[0]);
- if (x == 1 || x == 3) {
- return 6;
- }
- }
- return 4;
- }
- int sol(string s) {
- vector<int> cnt(10);
- for (auto c : s) ++cnt[c - '0'];
- int mx = *max_element(cnt.begin(), cnt.end());
- if (mx == 4) return -1;
- else if (mx == 3) return 6;
- else return 4;
- }
- /*
- 3
- 9546
- 0000
- 3313
- */
- int main()
- {
- int t; cin >> t;
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- for (int i = 0; i < t; ++i) {
- string s; cin >> s;
- int my = f(s);
- int he = sol(s);
- if (he != my) {
- cout << "WA\n";
- cout << "my = " << my << "\n";
- cout << "he = " << he << "\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement