Submission #439319

#TimeUsernameProblemLanguageResultExecution timeMemory
439319rainboyBit Shift Registers (IOI21_registers)C++17
75 / 100
9 ms1148 KiB
#include "registers.h" #include <vector> using namespace std; typedef vector<bool> vb; const int N = 128, L = 7, B = 2000; void construct_instructions(int s, int n, int k, int q) { int h, i, u, v, l; if (s == 0) { vb aa(B, 0), bit(B, 0); for (i = n; i < N; i++) aa[i * k + k - 1] = 1; bit[k - 1] = 1; append_store(1, aa), append_store(6, bit); for (h = k - 1; h >= 0; h--) { append_or(2, 0, 1), append_right(3, 2, k), append_and(3, 3, 2); if (n > 2) for (l = 1; l < L; l++) append_right(4, 3, k << l), append_and(3, 3, 4); append_and(3, 3, 6); append_or(5, 5, 3); if (h > 0) { for (l = 0; l < L; l++) if (l == 0 || n > 2) append_left(4, 3, k << l), append_or(3, 3, 4); append_not(3, 3), append_and(2, 2, 3), append_or(1, 1, 2); append_right(1, 1, 1), append_right(6, 6, 1); } } append_move(0, 5); } else { vb uu(B, 0); int h, l, l_; for (l = 0; l < L; l++) { if (l > 0) for (u = 0; u < N; u++) { if ((u & 1 << l) != 0 && (u & 1 << l - 1) == 0) { v = u ^ (1 << l) - 1; for (h = 0; h < B; h++) uu[h] = h / k == u; append_store(50, uu); append_right(1, 0, (v - u) * k), append_xor(1, 0, 1); append_and(1, 1, 50); append_left(2, 1, (v - u) * k); append_or(1, 1, 2); append_xor(0, 0, 1); } } for (l_ = l; l_ >= 0; l_--) { append_right(1, 0, k << l_); append_xor(2, 0, 1); append_not(1, 1), append_and(3, 0, 1), append_or(4, 0, 1), append_not(1, 1); append_move(5, 99); for (h = 0; h < k; h++) { append_or(5, 5, 3), append_and(5, 5, 4); if (h + 1 < k) append_left(5, 5, 1); else append_right(5, 5, k - 1); } for (u = 0; u < N; u++) for (h = 0; h < k; h++) uu[u * k + h] = (u & 1 << l_) == 0 && h == 0; append_store(75, uu), append_and(5, 5, 75); for (h = 0; h + 1 < k; h++) append_left(6, 5, 1), append_or(5, 5, 6); for (u = 0; u < N; u++) for (h = 0; h < k; h++) uu[u * k + h] = (u & 1 << l_) == 0; append_and(5, 5, 2); append_store(75, uu), append_and(5, 5, 75); append_left(6, 5, k << l_), append_or(5, 5, 6); append_xor(0, 0, 5); } } append_right(0, 0, (N - n) * k); } }

Compilation message (stderr)

registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:43:43: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   43 |      if ((u & 1 << l) != 0 && (u & 1 << l - 1) == 0) {
      |                                         ~~^~~
registers.cpp:44:24: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   44 |       v = u ^ (1 << l) - 1;
      |               ~~~~~~~~~^~~
#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...