답안 #955535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955535 2024-03-30T21:36:24 Z rainboy Who wants to live forever? (CERC12_B) C
1 / 1
27 ms 10452 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, j, dies;

		scanf("%s", cc), n = strlen(cc);
		l = 0;
		while ((n + 1 & 1 << l) == 0)
			l++;
		dies = 1;
		for (i = (1 << l) - 1; i < n; i += 1 << l) {
			if (cc[i] != '0') {
				dies = 0;
				break;
			}
			for (j = 1; j < 1 << l; j++)
				if (cc[i - j] != cc[i + j]) {
					dies = 0;
					break;
				}
		}
		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);
      |   ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 10 ms 1624 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 27 ms 10452 KB Output is correct