답안 #864691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864691 2023-10-23T12:39:22 Z Trisanu_Das Mensza (COI22_mensza) C++17
100 / 100
2183 ms 91476 KB
#include <stdio.h>
 
#define L	19
 
int main() {
	int q;
 
	scanf("%*d%d", &q);
	while (q--) {
		static char s[9];
		static int aa[L];
		int n, l, a, gt;
		scanf("%s", s);
		if (s[0] == 'a') {
			scanf("%d", &a);
			n = 0;
			for (l = 0; l < L; l++) if ((a & 1 << l) != 0) aa[n++] = a >> l + 1 | 1 << L - 1 - l;
			printf("%d", n);
			while (n--) printf(" %d", aa[n]);
			printf("\n");
		} else if (s[0] == 'b') {
			scanf("%d", &a);
			n = 0;
			for (l = 0; l < L; l++) if ((a & 1 << l) == 0) aa[n++] = a >> l + 1 | 1 << L - 1 - l;
			printf("%d", n);
			while (n--) printf(" %d", aa[n]);
			printf("\n");
		} else {
			scanf("%d", &n);
			gt = 0;
			while (n--) {
				scanf("%d", &a);
				if (a == 2) gt = 1;
			}
			printf(gt ? "A\n" : "B\n");
		}
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:17:68: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |    for (l = 0; l < L; l++) if ((a & 1 << l) != 0) aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                                                                  ~~^~~
Main.cpp:17:85: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   17 |    for (l = 0; l < L; l++) if ((a & 1 << l) != 0) aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                                                                                     ^
Main.cpp:24:68: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |    for (l = 0; l < L; l++) if ((a & 1 << l) == 0) aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                                                                  ~~^~~
Main.cpp:24:85: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   24 |    for (l = 0; l < L; l++) if ((a & 1 << l) == 0) aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                                                                                     ^
Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%*d%d", &q);
      |  ~~~~~^~~~~~~~~~~~~
Main.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
Main.cpp:15:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |    scanf("%d", &a);
      |    ~~~~~^~~~~~~~~~
Main.cpp:22:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |    scanf("%d", &a);
      |    ~~~~~^~~~~~~~~~
Main.cpp:29:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |    scanf("%d", &n);
      |    ~~~~~^~~~~~~~~~
Main.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d", &a);
      |     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1222 ms 2864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2183 ms 91476 KB Output is correct