Submission #466590

#TimeUsernameProblemLanguageResultExecution timeMemory
466590alexxela12345Bit Shift Registers (IOI21_registers)C++17
58 / 100
1 ms460 KiB
#include "registers.h" #include <bits/stdc++.h> using namespace std; const int B = 2000; void solve0(int n, int k, int q) { append_print(0); // make n a power of 2 { vector<bool> adding(B); bool was = 0; while (n & (n - 1)) { for (int i = n * k; i < (n + 1) * k; i++) { adding[i] = 1; } was = 1; n++; } if (was) { append_store(1, adding); append_xor(0, 0, 1); } } { // 8th cell is 1 vector<bool> one(B); one[0] = 1; append_store(8, one); } for (int len = 1; len < n; len *= 2) { vector<bool> mask_ones(B); for (int i = 0; i < n; i += 2 * len) { mask_ones[k + i * k] = 1; } append_store(6, mask_ones); append_print(0); // what single iteration does: // for i in range(0, n, 2 * len): // chkmin(a[i], a[i + len]) // after all iterations a[0] is min(a) vector<bool> mask_odd(B), mask_even(B); for (int i = 0; i * 2 * len < n; i++) { for (int j = 0; j < k; j++) { mask_even[i * 2 * len * k + j] = 1; mask_odd[(2 * i + 1) * len * k + j] = 1; } } append_store(1, mask_even); append_store(2, mask_odd); append_and(3, 0, 1); append_and(4, 0, 2); append_right(4, 4, len * k); append_print(3); append_print(4); append_not(4, 4); append_add(5, 3, 4); append_add(5, 5, 6); append_not(4, 4); append_print(5); append_and(6, 6, 5); append_right(7, 6, k); append_not(7, 7); append_add(7, 7, 8); append_add(7, 7, 6); append_print(7); append_and(4, 4, 7); append_not(7, 7); append_and(3, 3, 7); append_print(3); append_print(4); append_xor(0, 3, 4); } } void construct_instructions(int s, int n, int k, int q) { if (s == 0) { solve0(n, k, q); } }
#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...