Submission #774944

#TimeUsernameProblemLanguageResultExecution timeMemory
774944SanguineChameleonBit Shift Registers (IOI21_registers)C++17
47 / 100
1 ms300 KiB
#include "registers.h" #include <bits/stdc++.h> using namespace std; namespace sub0 { const int PLUS_ONE = 99; const int PLUS_ONE_LSB = 98; const int ONLY_MSB = 97; const int OFF_MSB = 96; const int MSB_ZERO = 95; const int MSB_ONE = 94; const int ALL_ONES = 93; const int ALL_ZEROES = 92; vector<bool> BITS(2000); void solve(int N, int K) { int pw = 1; while (pw < N) { pw <<= 1; } BITS[0] = 1; append_store(PLUS_ONE, BITS); BITS[0] = 0; for (int i = N * K; i < pw * K; i++) { BITS[i] = 1; } append_store(1, BITS); append_or(0, 0, 1); append_print(0); for (int i = N * K; i < pw * K; i++) { BITS[i] = 0; } N = pw; for (int i = 0; i < N * K; i++) { BITS[i] = 1; } append_store(ALL_ONES, BITS); append_not(ALL_ZEROES, ALL_ONES); for (int i = 0; i < N * K; i++) { BITS[i] = 0; } append_print(ALL_ONES); append_print(ALL_ZEROES); for (int i = 0; i < N; i++) { BITS[(i + 1) * K - 1] = 1; } append_store(ONLY_MSB, BITS); for (int i = 0; i < N; i++) { BITS[(i + 1) * K - 1] = 0; } for (int i = 0; i < N; i++) { BITS[i * K] = 1; } append_store(PLUS_ONE_LSB, BITS); append_print(PLUS_ONE_LSB); append_not(OFF_MSB, ONLY_MSB); append_print(PLUS_ONE); append_print(ONLY_MSB); append_print(OFF_MSB); append_not(1, 0); append_and(2, 1, ONLY_MSB); append_add(MSB_ZERO, 2, ALL_ONES); append_and(MSB_ZERO, MSB_ZERO, ALL_ZEROES); append_print(MSB_ZERO); append_right(MSB_ONE, MSB_ZERO, N * K); append_not(MSB_ONE, MSB_ONE); append_add(MSB_ZERO, MSB_ZERO, MSB_ONE); append_add(MSB_ZERO, MSB_ZERO, PLUS_ONE); append_not(MSB_ONE, MSB_ZERO); append_right(3, 2, K - 1); append_not(3, 3); append_add(2, 2, 3); append_add(2, 2, PLUS_ONE); append_print(2); append_and(1, 1, 2); append_print(1); append_not(1, 1); append_not(ONLY_MSB, ONLY_MSB); append_and(1, 1, ONLY_MSB); append_not(ONLY_MSB, ONLY_MSB); append_print(1); append_and(2, 0, ONLY_MSB); append_right(3, 2, K - 1); append_not(3, 3); append_add(2, 2, 3); append_add(2, 2, PLUS_ONE); append_and(2, 0, 2); append_print(1); append_print(2); append_print(MSB_ZERO); append_print(MSB_ONE); append_and(1, 1, MSB_ZERO); append_and(2, 2, MSB_ONE); append_add(0, 1, 2); while (N > 1) { append_print(0); append_print(1); append_print(2); append_right(1, 0, (N / 2) * K); append_not(2, 1); append_print(2); append_and(2, 2, OFF_MSB); append_print(2); append_add(2, 0, 2); append_print(2); append_print(PLUS_ONE_LSB); append_add(2, 2, PLUS_ONE_LSB); append_print(2); append_and(2, 2, ONLY_MSB); append_right(3, 2, K - 1); append_not(3, 3); append_add(2, 2, 3); append_add(2, 2, PLUS_ONE); append_not(3, 2); append_print(0); append_print(1); append_print(2); append_print(3); append_and(0, 0, 3); append_and(1, 1, 2); append_add(0, 0, 1); N /= 2; } append_and(ONLY_MSB, ONLY_MSB, MSB_ONE); append_add(0, 0, ONLY_MSB); append_print(0); append_print(MSB_ZERO); append_print(MSB_ONE); } } namespace sub1 { void solve(int n, int k) { } } void construct_instructions(int s, int n, int k, int q) { if (s == 0) { sub0::solve(n, k); } else { sub1::solve(n, 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...