Submission #997920

# Submission time Handle Problem Language Result Execution time Memory
997920 2024-06-13T06:37:24 Z Qwerty1232 MalnaRISC (COI21_malnarisc) C++17
100 / 100
1 ms 348 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++) {
                        if (k2 == k) {
                            ans.rbegin()[k2].push_back({i + i2 + j, i + i2 + ((1 << k2 + 1) - 1 - j)});
                        } else {
                            ans.rbegin()[k2].push_back({i + i2 + j, i + i2 + (1 << k2) + j});
                        }
                    }
                }
            }
        }
    }

    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:19:88: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   19 |                             ans.rbegin()[k2].push_back({i + i2 + j, i + i2 + ((1 << k2 + 1) - 1 - j)});
      |                                                                                     ~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct