Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- #include <cmath>
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <set>
- #include <map>
- #include <list>
- #include <time.h>
- #include <math.h>
- #include <random>
- #include <deque>
- #include <queue>
- #include <cassert>
- #include <unordered_map>
- #include <unordered_set>
- #include <iomanip>
- #include <bitset>
- #include <sstream>
- #include <chrono>
- #include <stack>
- typedef long long ll;
- bool check(string s) {
- for (int i = 0; i < s.size() / 2; ++i) {
- if (s[i] != s[(int)s.size() - i - 1]) {
- return false;
- }
- return true;
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- string s;
- cin >> s;
- int n = s.size();
- int r = n / 2;
- string p = "";
- for (int i = 0; i < n - 1; ++i) {
- p += s[i];
- string cur = "";
- for (int j = i + 1; j < n; ++j) {
- cur += s[j];
- }
- cur += p;
- if (check(cur)) {
- cout << 1;
- return 0;
- }
- }
- set<char> have;
- for (int i = 0; i < n / 2; ++i) {
- have.insert(s[i]);
- }
- if (have.size() == 1) {
- cout << "Impossible";
- return 0;
- }
- cout << 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement