Submission #997907

# Submission time Handle Problem Language Result Execution time Memory
997907 2024-06-13T06:24:22 Z Qwerty1232 MalnaRISC (COI21_malnarisc) C++17
0 / 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++) {
                        ans.rbegin()[k2].push_back({i + i2 + j, i + i2 + ((1 << k2 + 1) - 1 - j)});
                    }
                }
            }
        }
    }
    // 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 << " " << "R" << j +  << "  ";
    //     }
    //     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 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not sorted
2 Halted 0 ms 0 KB -