Submission #955531

# Submission time Handle Problem Language Result Execution time Memory
955531 2024-03-30T21:21:58 Z rainboy Who wants to live forever? (CERC12_B) C
0 / 1
0 ms 348 KB
#include <stdio.h>
#include <string.h>

#define N	200000

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		static char cc[N + 1];
		int n, l, i, dies;

		scanf("%s", cc), n = strlen(cc);
		l = 0;
		while ((n + 1 & 1 << l) == 0)
			l++;
		dies = 1;
		for (i = 1 << l; i < n; i++)
			if (cc[i] != cc[i - (1 << l)]) {
				dies = 0;
				break;
			}
		if (1 << l <= n && cc[(1 << l) - 1] != '0')
			dies = 0;
		printf(dies ? "DIES\n" : "LIVES\n");
	}
	return 0;
}

Compilation message

B.c: In function 'main':
B.c:16:13: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   16 |   while ((n + 1 & 1 << l) == 0)
      |           ~~^~~
B.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
B.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%s", cc), n = strlen(cc);
      |   ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -