Submission #829409

#TimeUsernameProblemLanguageResultExecution timeMemory
829409ymmBit Shift Registers (IOI21_registers)C++17
100 / 100
4 ms1160 KiB
#include "registers.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) typedef long long ll; using namespace std; const int b = 2000, m = 100; void do_swap(int k, int skip) { vector<bool> msk(b), msk1(b); for (int i = skip; i*k < b; i += 2) { msk1[i*k] = 1; Loop (j,i*k,min<int>(i*k+k,b)) msk[j] = 1; } vector<bool> msks(b); Loop (i,0,skip*k) msks[i] = 1; append_store(m-1, msk1); append_store(m-2, msk); append_store(m-3, msks); append_and(m-4, 0, m-3); append_right(1, 0, k); append_not(1, 1); append_and(0, 0, m-2); append_and(1, 1, m-2); append_print(0); append_print(1); append_add(2, 0, 1); append_right(2, 2, k); append_xor(2, 2, m-2); append_add(2, 2, m-1); append_and(2, 2, m-2); append_print(2); append_xor(1, 1, m-2); append_and(3, 0, 2); append_and(5, 1, 2); append_not(2, 2); append_and(4, 1, 2); append_and(6, 0, 2); append_print(3); append_print(4); append_print(5); append_print(6); append_xor(3, 3, 4); append_xor(5, 5, 6); append_left(5, 5, k); append_print(3); append_print(5); append_xor(0, 3, 5); append_print(0); append_xor(0, 0, m-4); append_print(0); } void Do(int k, int k2) { vector<bool> msk(b), msk1(b); for (int i = 0; i*k2 < b; i += 2) { msk1[i*k2] = 1; Loop (j,i*k2,min<int>(i*k2+k,b)) msk[j] = 1; } append_store(m-1, msk1); append_store(m-2, msk); append_right(1, 0, k2); append_not(1, 1); append_and(0, 0, m-2); append_and(1, 1, m-2); append_print(0); append_print(1); append_add(2, 0, 1); append_right(2, 2, k); append_xor(2, 2, m-2); append_add(2, 2, m-1); append_print(2); append_and(0, 0, 2); append_not(2, 2); append_not(1, 1); append_and(1, 1, 2); append_xor(0, 0, 1); } void construct_instructions(int s, int n, int k, int q) { int k2 = k; int cnt = 1; vector<bool> msk(b); Loop (i,0,n*k) msk[i] = 1; append_store(66, msk); append_xor(0, 0, 66); if (s == 0) { while (cnt < n) { Do(k, k2); k2 *= 2; cnt *= 2; } } else { Loop (i,0,n) do_swap(k, i&1); } append_xor(0, 0, 66); }
#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...