Submission #781188

# Submission time Handle Problem Language Result Execution time Memory
781188 2023-07-12T22:04:48 Z rainboy Mensza (COI22_mensza) C++17
34 / 100
5000 ms 159492 KB
#include <stdio.h>
#include <string.h>

#define L	10
#define N	110

int main() {
	int q;

	scanf("%*d%d", &q);
	while (q--) {
		static char s[9];
		static int aa[N], mask[N];
		int n, l, a, x, k;

		scanf("%s", s);
		if (s[0] == 'a') {
			scanf("%d", &a);
			n = 0;
			for (l = 0; l < L; l++) {
				k = (a & 1 << l) == 0 ? l * 2 + 0 : l * 2 + 1;
				while (k--)
					aa[n++] = 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++) {
				k = (a & 1 << l) == 0 ? l * 2 + 0 : l * 2 + 2;
				while (k--)
					aa[n++] = l;
			}
			printf("%d", n);
			while (n--)
				printf(" %d", aa[n]);
			printf("\n");
		} else {
			scanf("%d", &n);
			memset(mask, 0, L * sizeof *mask);
			while (n--) {
				scanf("%d", &x);
				mask[x / 4] = x % 4;
			}
			for (l = L - 1; l >= 0; l--)
				if (mask[l] != 0 && mask[l] != 3) {
					printf(mask[l] == 1 ? "A\n" : "B\n");
					break;
				}
		}
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%*d%d", &q);
      |  ~~~~~^~~~~~~~~~~~~
Main.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
Main.cpp:18:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |    scanf("%d", &a);
      |    ~~~~~^~~~~~~~~~
Main.cpp:30:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |    scanf("%d", &a);
      |    ~~~~~^~~~~~~~~~
Main.cpp:42:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |    scanf("%d", &n);
      |    ~~~~~^~~~~~~~~~
Main.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     scanf("%d", &x);
      |     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 751 ms 3316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5033 ms 159492 KB Time limit exceeded
2 Halted 0 ms 0 KB -