Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. //#pragma GCC optimize("Ofast")
  2. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
  3. //#pragma GCC optimize("unroll-loops")
  4.  
  5. #include <bits/stdc++.h>
  6.  
  7. #include <ext/pb_ds/assoc_container.hpp>
  8. #include <ext/pb_ds/tree_policy.hpp>
  9. #include <ext/pb_ds/detail/standard_policies.hpp>
  10.  
  11. #define pb push_back
  12. #define F first
  13. #define S second
  14. #define lll long long
  15. #define lld long double
  16.  
  17. using namespace std;
  18. using namespace __gnu_pbds;
  19.  
  20. template <typename T>
  21. using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
  22.  
  23. const int N = 3e5;
  24. const int M = 1e9 + 83;
  25. const int M2 = 1e9 + 7;
  26. const int MM = 1e9 + 7;
  27. const int mod = 998244353;
  28. const int rx[8] = {1, 1, -1, -1, -2, -2, 2, 2};
  29. const int ry[8] = {-2, 2, -2, 2, 1, -1, 1, -1};
  30. const lld eps = 1e-8;
  31. const double pi = acos(-1.0);
  32.  
  33. int main() {
  34. ios_base::sync_with_stdio(0);
  35. cin.tie(0);
  36. cout.tie(0);
  37. srand(time(0));
  38. #ifdef LOCAL
  39. freopen("input.txt", "r", stdin);
  40. freopen("output.txt", "w", stdout);
  41. #else
  42. // freopen("dictionary.in", "r", stdin);
  43. // freopen("dictionary.out", "w", stdout);
  44. #endif
  45. string t, s, now;
  46. cin >> t;
  47. int f = 0, mem = 0;
  48. int n = int(t.size());
  49. for (int i = 1; i < n / 2; ++i) {
  50. if (t[i] != t[0]) {
  51. f = 1;
  52. }
  53. }
  54. if (!f) {
  55. cout << "Impossible";
  56. return 0;
  57. }
  58. int k = 0;
  59. f = 0;
  60. for (int len = 1; len <= n / 2; ++len) {
  61. now += t[len - 1];
  62. s = now;
  63. reverse(s.begin(), s.end());
  64. if (now != s) {
  65. continue;
  66. }
  67. if ((n / 2) % len) {
  68. continue;
  69. }
  70. f = 0;
  71. for (int i = len; i < (n / 2); ++i) {
  72. if (t[i] != t[i % len]) {
  73. f = 1;
  74. break;
  75. }
  76. }
  77. if (!f) {
  78. mem = 1;
  79. }
  80. if (!f && len % 2 == 0) {
  81. k = 1;
  82. break;
  83. }
  84. if (!f) {
  85. break;
  86. }
  87. }
  88. if (!mem || (n % 2)) {
  89. cout << 1 + (n % 2);
  90. } else {
  91. cout << 2 - k;
  92. }
  93. return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement