Submission #850618

# Submission time Handle Problem Language Result Execution time Memory
850618 2023-09-17T07:24:44 Z Cyanmond Mensza (COI22_mensza) C++17
100 / 100
2425 ms 137564 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()
 
using i64 = long long;
 
void main_() {
    int L, Q;
    scanf("%d%d", &L, &Q);
    while (Q--) {
        char name[10];
        scanf("%s", &name);
        if (name[0] == 'a') {
            int N;
            scanf("%d", &N);
            vector<int> ret;
            int v = 0;
            per(i, 0, 19) {
                if (N & (1 << i)) {
                    v |= 1 << i;
                    ret.push_back(v);
                }
            }
 
            printf("%d", ret.size());
            for (const auto e : ret) printf(" %d", e);
            printf("\n");
        }
        if (name[0] == 'b') {
            int N;
            scanf("%d", &N);
            vector<int> ret;
            int v = 0;
            per(i, 0, 19) {
                if (N & (1 << i)) {
                    v |= 1 << i;
                } else {
                    ret.push_back(v | (1 << i));
                }
            }
 
            printf("%d", ret.size());
            for (const auto e : ret) printf(" %d", e);
            printf("\n");
        }
        if (name[0] == 'c') {
            int N;
            scanf("%d", &N);
            vector<int> c(N);
            for (auto &e : c) scanf("%d", &e);
 
            bool ans = c.back() == 1;
            if (ans) printf("B\n");
            else printf("A\n");
        }
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    main_();
}

Compilation message

Main.cpp: In function 'void main_()':
Main.cpp:16:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[10]' [-Wformat=]
   16 |         scanf("%s", &name);
      |                ~^   ~~~~~
      |                 |   |
      |                 |   char (*)[10]
      |                 char*
Main.cpp:29:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   29 |             printf("%d", ret.size());
      |                     ~^   ~~~~~~~~~~
      |                      |           |
      |                      int         std::vector<int>::size_type {aka long unsigned int}
      |                     %ld
Main.cpp:46:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   46 |             printf("%d", ret.size());
      |                     ~^   ~~~~~~~~~~
      |                      |           |
      |                      int         std::vector<int>::size_type {aka long unsigned int}
      |                     %ld
Main.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d", &L, &Q);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%s", &name);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |             scanf("%d", &N);
      |             ~~~~~^~~~~~~~~~
Main.cpp:35:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |             scanf("%d", &N);
      |             ~~~~~^~~~~~~~~~
Main.cpp:52:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |             scanf("%d", &N);
      |             ~~~~~^~~~~~~~~~
Main.cpp:54:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |             for (auto &e : c) scanf("%d", &e);
      |                               ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1255 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2425 ms 137564 KB Output is correct