Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <map>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main() {
- map<char, int> mp = map<char, int>();
- mp['J'] = 0;
- mp['L'] = 1;
- mp['S'] = 2;
- mp['Z'] = 3;
- mp['I'] = 4;
- mp['O'] = 5;
- mp['T'] = 6;
- int T;
- cin >> T;
- while (T-- > 0) {
- string s;
- cin >> s;
- int l = s.length();
- vector<int> v = vector<int>(l);
- for (int i = 0; i < l; i++) {
- v[i] = mp[s[i]];
- }
- bool pass = false;
- for (int j = 0; j < 7; j++) {
- bool current = true;
- set<int> vals = set<int>();
- for (int i = 0; i < j; i++) {
- vals.insert(v[i]);
- }
- if (vals.size() != j) {
- current = false;
- } else {
- vals = set<int>();
- int counter = 0;
- for (int i = j; i < l; i++) {
- counter++;
- vals.insert(v[i]);
- if (counter == 7) {
- if (7 != vals.size()) {
- current = false;
- break;
- }
- counter = 0;
- vals = set<int>();
- }
- }
- if (vals.size() != counter) {
- current = false;
- }
- }
- if (current) {
- pass = true;
- break;
- }
- }
- if (pass) {
- cout << 1 << endl;
- } else {
- cout << 0 << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment