Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1.  
  2. using namespace std;
  3. #include <cmath>
  4. #include <iostream>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <string>
  8. #include <set>
  9. #include <map>
  10. #include <list>
  11. #include <time.h>
  12. #include <math.h>
  13. #include <random>
  14. #include <deque>
  15. #include <queue>
  16. #include <cassert>
  17. #include <unordered_map>
  18. #include <unordered_set>
  19. #include <iomanip>
  20. #include <bitset>
  21. #include <sstream>
  22. #include <chrono>
  23. #include <stack>
  24.  
  25. typedef long long ll;
  26.  
  27.  
  28. bool check(string s) {
  29. for (int i = 0; i < s.size() / 2; ++i) {
  30. if (s[i] != s[(int)s.size() - i - 1]) {
  31. return false;
  32. }
  33. return true;
  34. }
  35. }
  36. int main() {
  37. ios::sync_with_stdio(false);
  38. string s;
  39. cin >> s;
  40. int n = s.size();
  41. int r = n / 2;
  42. string p = "";
  43. for (int i = 0; i < n - 1; ++i) {
  44. p += s[i];
  45. string cur = "";
  46. for (int j = i + 1; j < n; ++j) {
  47. cur += s[j];
  48. }
  49. cur += p;
  50. if (check(cur)) {
  51. cout << 1;
  52. return 0;
  53. }
  54. }
  55. set<char> have;
  56. for (int i = 0; i < n / 2; ++i) {
  57. have.insert(s[i]);
  58. }
  59. if (have.size() == 1) {
  60. cout << "Impossible";
  61. return 0;
  62. }
  63. cout << 2;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement