제출 #795271

#제출 시각아이디문제언어결과실행 시간메모리
795271finn__레지스터 (IOI21_registers)C++17
47 / 100
1 ms340 KiB
#include "registers.h" #include <vector> #include <iostream> constexpr size_t B = 2000; constexpr int ONE = 50, ALL_ONES = 51, MASK = 52, K_MASK = 53, ALL_ZEROS = 54; void construct_instructions(int s, int n, int k, int q) { std::vector<bool> r(B); r[0] = 1; append_store(ONE, r); fill(r.begin() + 1, r.end(), 1); append_store(ALL_ONES, r); fill(r.begin(), r.end(), 0); for (int i = k; i < B; i += k) r[i] = 1; append_store(MASK, r); fill(r.begin() + k, r.end(), 0); fill(r.begin(), r.begin() + k, 1); append_store(K_MASK, r); fill(r.begin(), r.end(), 0); append_store(ALL_ZEROS, r); // writes min in a, max in b auto append_swap = [&](int a, int b) { append_not(40, a); append_add(40, 40, ONE); append_add(40, 40, b); // 40 : b - a append_xor(41, 40, a); append_xor(41, 41, b); // 41 : (b - a) ^ a ^ b append_and(40, 41, MASK); append_right(41, 40, k); append_not(41, 41); append_add(41, 41, ONE); append_add(42, 40, 41); // 42 : 1-mask if a > b, else 0-mask append_xor(43, a, b); append_and(43, 43, 42); // 43 : a_i ^ b_i if a_i > b_i append_xor(a, a, 43); // a_i = min(a_i, b_i) append_xor(b, b, 43); // b_i = max(a_i, b_I) }; if (!s) { int l = 64; append_left(2, ALL_ONES, n * k); append_or(0, 0, 2); append_move(1, 0); append_right(0, 0, l * k); // 0 : upper half append_left(2, ALL_ONES, l * k); append_or(1, 1, 2); // 1 : lower half append_print(0); append_print(1); while (l) { append_swap(0, 1); l >>= 1; append_move(1, 0); append_right(0, 0, l * k); append_left(2, ALL_ONES, l * k); append_or(1, 1, 2); append_print(0); append_print(1); } } else { for (int i = 0; i < n; ++i) { if (!(i & 1)) { append_right(10, 0, i - i / 2); append_left(11, K_MASK, i / 2); append_and(10, 10, 11); append_or(2, 2, 10); } else { append_right(10, 0, i - i / 2); append_left(11, K_MASK, i / 2); append_and(10, 10, 11); append_or(3, 3, 10); } } append_left(10, ALL_ONES, ((n + 1) / 2) * k); append_or(2, 2, 10); append_left(10, ALL_ONES, (n / 2) * k); append_or(3, 3, 10); for (int j = 0; j < 2 * n - 3; ++j) { append_swap(2, 3); if (!(j & 1)) { append_left(3, 3, k); append_or(3, 3, K_MASK); } else { append_right(3, 3, k); } } append_move(0, ALL_ZEROS); for (int i = 0; i < n; ++i) { if (!(i & 1)) { append_and(10, 2, K_MASK); append_or(0, 0, 10); append_left(0, 0, k); append_right(2, 2, k); } else { append_and(10, 3, K_MASK); append_or(0, 0, 10); append_left(0, 0, k); append_right(3, 3, k); } } } }

컴파일 시 표준 에러 (stderr) 메시지

registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'const size_t' {aka 'const long unsigned int'} [-Wsign-compare]
   16 |     for (int i = k; i < B; i += k)
      |                     ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...