제출 #439998

#제출 시각아이디문제언어결과실행 시간메모리
439998haojiandan레지스터 (IOI21_registers)C++17
100 / 100
2 ms588 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 if (n<=10) { int ANS=94,R1=93,R2=92,R3=91,R4=6,all=5; A=vector<bool>(b,0); for (int i=0;i<k;i++) A[i]=1; append_store(R1,A); for (int i=0;i<n*k;i++) A[i]=1; append_store(all,A); int One=89,OOne=88; A=vector<bool>(b,0); A[0]=1; append_store(One,A); A=vector<bool>(b,0); A[(n+1)*k]=1; append_store(OOne,A); append_print(OOne); A=vector<bool>(b,0); for (int i=n*k;i<(n+1)*k;i++) A[i]=1; append_store(R3,A); A=vector<bool>(b,0); for (int i=(n+1)*k;i<(n+2)*k;i++) A[i]=1; append_store(R4,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); append_print(0); int lst=85-i+1,lst2=lst-40,rub=4; append_move(lst2,R1); append_not(lst,lst); for (int j=1;j<=n;j++) { append_xor(R2,r,0); append_and(R2,R2,lst2); append_not(R2,R2); append_and(R2,R2,all); append_add(R2,R2,One); // n*k append_add(R2,R2,R3); // (n+1)*k; append_and(R2,R2,lst); append_move(rub,R2); append_not(rub,rub); append_and(lst,lst,rub); append_and(R2,R2,OOne); append_xor(R2,R2,OOne); append_add(R2,R2,R4); append_right(R2,R2,(n+2)*k-j*k); append_and(R2,R2,lst2); append_or(0,0,R2); append_left(r,r,k); append_left(lst2,lst2,k); } append_print(ANS); } append_move(0,ANS); } else { int x=80,y=81; append_or(0,0,99); for (int i=0;i<n;i++) { if (i&1) append_left(1,0,k); else append_right(1,0,k); 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_not(4,3); append_and(x,3,0); append_and(y,4,1); append_or(A0,x,y); append_and(A0,A0,r1); append_and(x,3,1); append_and(y,4,0); append_or(A1,x,y); append_and(A1,A1,r1); if (i&1) append_right(A0,A0,k); else append_left(A1,A1,k); append_or(0,A0,A1); } } }

컴파일 시 표준 에러 (stderr) 메시지

registers.cpp: In function 'void construct_instructions(int, int, int, int)':
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...