Submission #591530

#TimeUsernameProblemLanguageResultExecution timeMemory
591530rainboyBit Shift Registers (IOI21_registers)C++17
100 / 100
7 ms1176 KiB
#include "registers.h" #include <vector> using namespace std; typedef vector<bool> vb; int N = 128, L = 7; const int B = 2000; void construct_instructions(int s, int n, int k, int q) { vb tmp(B, 0); int h, u, v, l, l_; if (s == 0) { if (n <= 2) N = 2, L = 1; for (h = 0; h < B; h++) tmp[h] = h / k >= n; append_store(25, tmp), append_or(0, 0, 25); for (h = 0; h < B; h++) tmp[h] = 0; for (l = 0; l < L; l++) { for (u = 0; u < N; u++) for (h = 0; h < k; h++) tmp[u * k + h] = (u & (1 << l + 1) - 1) == 0; append_store(25, tmp); append_right(2, 0, k << l), append_and(1, 0, 25), append_and(2, 2, 25), append_xor(3, 1, 2); append_not(1, 1), append_add(4, 1, 2), append_not(1, 1); for (u = 0; u < N; u++) for (h = 0; h < k; h++) tmp[u * k + h] = (u & (1 << l + 1) - 1) == 0 && h == 0; append_store(25, tmp), append_right(4, 4, k), append_and(4, 4, 25); for (u = 0; u < N; u++) for (h = 0; h < k; h++) tmp[u * k + h] = (u == 0 || (u - 1 & (1 << l + 1) - 1) == 0) && h == 0; append_store(25, tmp), append_not(4, 4), append_add(4, 25, 4); append_and(3, 3, 4); append_left(4, 3, k << l), append_or(3, 3, 4); append_xor(0, 0, 3); } } else { if (n == 2) N = n, L = 1; 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++) tmp[h] = h / k == u; append_store(29, tmp); append_right(1, 0, (v - u) * k), append_xor(1, 0, 1); append_and(1, 1, 29); 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++) tmp[u * k + h] = (u & 1 << l_) == 0 && h == 0; append_store(29, tmp), append_and(5, 5, 29); 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++) tmp[u * k + h] = (u & 1 << l_) == 0; append_and(5, 5, 2); append_store(29, tmp), append_and(5, 5, 29); 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:26:36: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   26 |      tmp[u * k + h] = (u & (1 << l + 1) - 1) == 0;
      |                                  ~~^~~
registers.cpp:26:41: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   26 |      tmp[u * k + h] = (u & (1 << l + 1) - 1) == 0;
      |                            ~~~~~~~~~~~~~^~~
registers.cpp:32:36: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   32 |      tmp[u * k + h] = (u & (1 << l + 1) - 1) == 0 && h == 0;
      |                                  ~~^~~
registers.cpp:32:41: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   32 |      tmp[u * k + h] = (u & (1 << l + 1) - 1) == 0 && h == 0;
      |                            ~~~~~~~~~~~~~^~~
registers.cpp:36:51: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   36 |      tmp[u * k + h] = (u == 0 || (u - 1 & (1 << l + 1) - 1) == 0) && h == 0;
      |                                                 ~~^~~
registers.cpp:36:37: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   36 |      tmp[u * k + h] = (u == 0 || (u - 1 & (1 << l + 1) - 1) == 0) && h == 0;
      |                                   ~~^~~
registers.cpp:48:43: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   48 |      if ((u & 1 << l) != 0 && (u & 1 << l - 1) == 0) {
      |                                         ~~^~~
registers.cpp:49:24: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   49 |       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...