Submission #781881

# Submission time Handle Problem Language Result Execution time Memory
781881 2023-07-13T12:37:54 Z rainboy Mensza (COI22_mensza) C++17
100 / 100
2194 ms 91284 KB
/* https://codeforces.com/blog/entry/103280#comment-917355 */
#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:21:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |      aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                     ~~^~~
Main.cpp:21:40: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   21 |      aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                                        ^
Main.cpp:31:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |      aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                     ~~^~~
Main.cpp:31:40: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   31 |      aa[n++] = a >> l + 1 | 1 << L - 1 - l;
      |                                        ^
Main.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%*d%d", &q);
      |  ~~~~~^~~~~~~~~~~~~
Main.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
Main.cpp:17:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |    scanf("%d", &a);
      |    ~~~~~^~~~~~~~~~
Main.cpp:27:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |    scanf("%d", &a);
      |    ~~~~~^~~~~~~~~~
Main.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |    scanf("%d", &n);
      |    ~~~~~^~~~~~~~~~
Main.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     scanf("%d", &a);
      |     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1266 ms 2660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2194 ms 91284 KB Output is correct