// CERC 2012 // Problem B: Who wants to live forever? // Brute-force simulating solution - TLE // Author: Bartosz Walczak #include #include #include #include using namespace std; typedef unsigned long type; const int group = sizeof(type)*8; const int iterations = INT_MAX; char str[1000001]; type table[1000000/group+2]; void testcase() { gets(str); int n = strlen(str); int m = n/group+1, r = n%group; type b = 1U; int index = 0; for (int i=0; i<=m; ++i) table[i] = 0U; for (int i=0; i('0'-str[i]); index += b>>group-1; b = b<<1 | b>>group-1; } for (int iter = min(iterations, n); iter; --iter) { type last = 0U; for (int i=0; i>group-1) ^ (table[i]>>1 | table[i+1]<(1U)<