Submission #439441

#TimeUsernameProblemLanguageResultExecution timeMemory
439441haojiandanBit Shift Registers (IOI21_registers)C++17
58 / 100
1 ms460 KiB
#include "registers.h" #include <bits/stdc++.h> using namespace std; void construct_instructions(int s, int n, int k, int q) { int m=100,b=2000; vector<bool> A(b,0); for (int i=n*k;i<b;i++) A[i]=1; append_store(99,A); int r1=98,r2=97,A0=96,A1=95; for (int i=0;i<b;i++) if ((i/k)%2==0) A[i]=1; else A[i]=0; append_store(r1,A); for (int i=0;i<b;i++) if (i%(k*2)==0) A[i]=1; else A[i]=0; append_store(r2,A); if (s==0) { append_or(0,0,99); int a=1; while (a<n) { append_right(1,0,a*k); a*=2; append_not(2,1); append_and(2,2,r1); append_and(0,0,r1); append_add(3,0,2); append_right(3,3,k); append_and(3,3,r2); append_add(3,3,r1); append_and(A0,3,0); append_not(3,3); append_and(A1,3,1); append_or(0,A0,A1); } } else { int ANS=94,R1=93,R2=92,R3=91; A=vector<bool>(b,0); for (int i=0;i<k;i++) A[i]=1; append_store(R1,A); int One=89; A=vector<bool>(b,0); A[n*k]=1; append_store(One,A); A=vector<bool>(b,0); for (int i=n*k;i<(n+1)*k;i++) A[i]=1; append_store(R3,A); for (int i=1;i<=n;i++) { int a=1,r=90; append_move(r,0); append_or(r,r,99); while (a<n) { append_right(1,r,a*k); a*=2; append_not(2,1); append_and(2,2,r1); append_and(r,r,r1); append_add(3,r,2); append_right(3,3,k); append_and(3,3,r2); append_add(3,3,r1); append_and(A0,3,r); append_not(3,3); append_and(A1,3,1); append_or(r,A0,A1); } append_and(r,r,R1); append_left(R2,r,(i-1)*k); append_or(ANS,ANS,R2); int lst=85-i+1; for (int j=1;j<=n;j++) { append_xor(R2,r,0); append_print(R2); append_not(R2,R2); append_and(R2,R2,One); // n*k append_print(R2); append_add(R2,R2,R3); // (n+1)*k; append_xor(R2,R2,lst); append_and(lst,lst,R2); append_not(R2,R2); append_and(R2,R2,R3); append_right(R2,R2,(n+1)*k-j*k); append_or(0,0,R2); append_left(r,r,k); } } append_move(0,ANS); } }

Compilation message (stderr)

registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:8:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    8 |    for (int i=n*k;i<b;i++) A[i]=1; append_store(99,A);
      |    ^~~
registers.cpp:8:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    8 |    for (int i=n*k;i<b;i++) A[i]=1; append_store(99,A);
      |                                    ^~~~~~~~~~~~
registers.cpp:6:6: warning: unused variable 'm' [-Wunused-variable]
    6 |  int m=100,b=2000;
      |      ^
#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...