답안 #997906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
997906 2024-06-13T06:21:58 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 << ans.size() << "\n";
    for (auto& vec : ans) {
        for (auto [a, b] : vec) {
            if (a < n0 && b < n0) {
                std::cout << "CMPSWP" << " " << "R" << a << " " << "R" << b << "  ";
            }
        }
        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)});
      |                                                                                 ~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -