Submission #917285

# Submission time Handle Problem Language Result Execution time Memory
917285 2024-01-27T16:03:19 Z NK_ Mensza (COI22_mensza) C++17
100 / 100
2264 ms 139980 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())

using ll = long long;
template<class T> using V = vector<T>;
using vl = V<ll>;
using vi = V<int>;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int L, Q; scanf("%d %d", &L, &Q);

	char s[10];
	for(int q = 0; q < Q; q++) {
		scanf("%8s", &s);

		if (s[0] == 'a') {
			int a; scanf("%d", &a); int cur = 0;
			vi res; for(int i = 18; i >= 0; i--) {
				if ((a >> i) & 1) {
					cur |= (1 << i);
					res.pb(cur);
				}
			} 

			printf("%d\n", sz(res));
			for(auto& x : res) printf("%d ", x);
			putchar('\n');
		}

		if (s[0] == 'b') {
			int b; scanf("%d", &b); int cur = 0;
			vi res; for(int i = 18; i >= 0; i--) {
				if ((b >> i) & 1) {
					cur |= (1 << i);
				} else res.pb(cur | (1 << i));
			} 

			printf("%d\n", sz(res));
			for(auto& x : res) printf("%d ", x);
			putchar('\n');
		}

		if (s[0] == 'c') {
			int k; scanf("%d", &k);
			vi A(k); for(auto& x : A) scanf("%d", &x);

			if (A.back() != 1) printf("A\n");
			else printf("B\n");
		}
	}

	exit(0-0);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:12: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[10]' [-Wformat=]
   22 |   scanf("%8s", &s);
      |          ~~^   ~~
      |            |   |
      |            |   char (*)[10]
      |            char*
Main.cpp:18:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  int L, Q; scanf("%d %d", &L, &Q);
      |            ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%8s", &s);
      |   ~~~~~^~~~~~~~~~~
Main.cpp:25:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |    int a; scanf("%d", &a); int cur = 0;
      |           ~~~~~^~~~~~~~~~
Main.cpp:39:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |    int b; scanf("%d", &b); int cur = 0;
      |           ~~~~~^~~~~~~~~~
Main.cpp:52:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |    int k; scanf("%d", &k);
      |           ~~~~~^~~~~~~~~~
Main.cpp:53:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |    vi A(k); for(auto& x : A) scanf("%d", &x);
      |                              ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1198 ms 2844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2264 ms 139980 KB Output is correct