#include inline int my_getchar(){ static char buf[1024]; static int s = 1024; static int e = 1024; if(s == e && e == 1024){ e = fread(buf, 1, 1024, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } inline void rd(int *px){ int k; int m=0; int x=0; for(;;){ k = my_getchar(); if(k=='-'){ m=1; break; } if('0'<=k&&k<='9'){ x=k-'0'; break; } } for(;;){ k = my_getchar(); if(k<'0'||k>'9'){ break; } x=x*10+k-'0'; } if(m){ x=-x; } *px = x; } struct MY_WRITER{ char buf[16384]; int s; int e; MY_WRITER(){ s = 0; e = 16384; } ~MY_WRITER(){ if(s){ fwrite(buf, 1, s, stdout); } } } ; MY_WRITER MY_WRITER_VAR; void my_putchar(int a){ if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){ fwrite(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout); MY_WRITER_VAR.s = 0; } MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a; } inline void wt_L(char a){ my_putchar(a); } inline void wt_L(int x){ int s=0; int m=0; char f[10]; if(x<0){ m=1; x=-x; } while(x){ f[s++]=x%10; x/=10; } if(!s){ f[s++]=0; } if(m){ my_putchar('-'); } while(s--){ my_putchar(f[s]+'0'); } } inline void wt_L(const char c[]){ int i=0; for(i=0;c[i]!='\0';i++){ my_putchar(c[i]); } } int N; int K; int anscnt = 0; void push_upd(int i,int x){ anscnt++; wt_L("UPD"); wt_L(' '); wt_L(i); wt_L(' '); wt_L(x); wt_L('\n'); } void push_and(int i,int x,int y){ anscnt++; wt_L("AND"); wt_L(' '); wt_L(i); wt_L(' '); wt_L(x); wt_L(' '); wt_L(y); wt_L('\n'); } void push_xor(int i,int x,int y){ anscnt++; wt_L("XOR"); wt_L(' '); wt_L(i); wt_L(' '); wt_L(x); wt_L(' '); wt_L(y); wt_L('\n'); } void add1(int l1,int r1,int b){ int n = N; for(int i=l1; i>= 1; if(k & 1){ push_and(p,i,p); } else{ push_upd(i-1,1); push_xor(p,i-1,p); push_xor(i,i-1,i); push_and(p,i,p); push_xor(p,i-1,p); } } } int xc[] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6 }; void solve(int n,int k){ anscnt = 0; for(int i=1; i 549) return 1; for(; anscnt<549; anscnt++){ wt_L("UPD 0 0"); wt_L('\n'); } return 0; } // cLay varsion 20201003-1 // --- original code --- // // int N,K; // int anscnt = 0; // // void push_upd(int i,int x){ anscnt++; wt("UPD",i,x); } // void push_and(int i,int x,int y){ anscnt++; wt("AND",i,x,y); } // void push_xor(int i,int x,int y){ anscnt++; wt("XOR",i,x,y); } // // void add1(int l1,int r1,int b){ // int n = N; // for(int i=l1; i>= 1; // if(k & 1) push_and(p,i,p); // else{ // push_upd(i-1,1); // push_xor(p,i-1,p); // push_xor(i,i-1,i); // push_and(p,i,p); // push_xor(p,i-1,p); // } // } // } // // int xc[] = { // 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, // 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, // 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, // 6,6,6 // }; // // void solve(int n,int k){ // anscnt = 0; // for(int i=1; i 633) exit(1); // for(; anscnt<633; anscnt++) wt("UPD 0 0"); // return 0; // }