Submission #997910

# Submission time Handle Problem Language Result Execution time Memory
997910 2024-06-13T06:25:56 Z Qwerty1232 MalnaRISC (COI21_malnarisc) C++17
15 / 100
4 ms 604 KB
#include <bits/stdc++.h>

int32_t main() {
    int n0;
    std::cin >> n0;
    int n = 1 << std::__lg(std::max(1, n0 - 1)) + 1;
    if (n0 == 1) {
        n = 1;
    }

    std::vector<std::vector<std::pair<int, int>>> ans;
    for (int k = 0; (1 << k) < n; k++) {
        ans.insert(ans.end(), k + 1, {});
        for (int i = 0; i < n; i += 1 << k + 1) {
            for (int k2 = k; k2 >= 0; k2--) {
                for (int i2 = 0; i2 < (1 << k + 1); i2 += (1 << k2 + 1)) {
                    for (int j = 0; j < (1 << k2); j++) {
                        ans.rbegin()[k2].push_back({i + i2 + j, i + i2 + ((1 << k2 + 1) - 1 - j)});
                    }
                }
            }
        }
    }

    n = n0;
    std::cout << 2 * n << "\n";
    for (int i = 0; i < 2 * n; i++) {
        for (int j = i % 2; j + 1 < n; j += 2) {
            std::cout << "CMPSWP" << " " << "R" << j + 1 << " " << "R" << j + 2 << "  ";
        }
        std::cout << std::endl;
    }

    // std::cout << ans.size() << "\n";
    // for (auto& vec : ans) {
    //     for (auto [a, b] : vec) {
    //         if (a < n0 && b < n0) {
    //             std::cout << "CMPSWP" << " " << "R" << a + 1 << " " << "R" << b + 1 << "  ";
    //         }
    //     }
    //     std::cout << std::endl;
    // }

    return 0;
}

Compilation message

malnarisc.cpp: In function 'int32_t main()':
malnarisc.cpp:6:49: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    6 |     int n = 1 << std::__lg(std::max(1, n0 - 1)) + 1;
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
malnarisc.cpp:14:44: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   14 |         for (int i = 0; i < n; i += 1 << k + 1) {
      |                                          ~~^~~
malnarisc.cpp:16:47: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   16 |                 for (int i2 = 0; i2 < (1 << k + 1); i2 += (1 << k2 + 1)) {
      |                                             ~~^~~
malnarisc.cpp:16:68: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   16 |                 for (int i2 = 0; i2 < (1 << k + 1); i2 += (1 << k2 + 1)) {
      |                                                                 ~~~^~~
malnarisc.cpp:18:84: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   18 |                         ans.rbegin()[k2].push_back({i + i2 + j, i + i2 + ((1 << k2 + 1) - 1 - j)});
      |                                                                                 ~~~^~~
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 4 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 344 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 604 KB Partially correct