結果

問題 No.142 単なる配列の操作に関する実装問題
ユーザー LayCurseLayCurse
提出日時 2015-02-02 03:12:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 780 ms / 5,000 ms
コード長 2,393 bytes
コンパイル時間 1,230 ms
コンパイル使用メモリ 146,740 KB
実行使用メモリ 24,796 KB
最終ジャッジ日時 2023-09-05 10:49:13
合計ジャッジ時間 5,727 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
24,764 KB
testcase_01 AC 633 ms
24,724 KB
testcase_02 AC 780 ms
24,736 KB
testcase_03 AC 198 ms
24,780 KB
testcase_04 AC 622 ms
24,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define ll long long
#define ull unsigned ll

void bitXOR(ull a[], ull b[], int stA, int stB, int len){int i,B,E,R,Y,X,G,Z;static ull p[65],q[65];static int f=0;if(!f){f=1;p[0]=0;rep(i,64)p[i+1]=(p[i]<<1)|1ULL;rep(i,65)q[i]=p[64]^p[i];}B=stA/64;E=stA%64;R=(stA+len)/64;Y=(stA+len)%64;X=stA-stB;G=X/64;Z=X%64;if(Z<0)Z+=64,G--;if(stA>stB){if(B==R){if(Z)b[B-G-1]^=(a[B]&p[Y]&q[E])<<(64-Z);b[B-G]^=(a[B]&p[Y]&q[E])>>Z;}else{if(Z)b[B-G-1]^=(a[B]&q[E])<<(64-Z);b[B-G]^=(a[B]&q[E])>>Z;REP(i,B+1,R){if(Z)b[i-G-1]^=a[i]<<(64-Z);b[i-G]^=a[i]>>Z;}if(Z)b[R-G-1]^=(a[R]&p[Y])<<(64-Z);b[R-G]^=(a[R]&p[Y])>>Z;}}else{if(B==R){b[B-G]^=(a[B]&p[Y]&q[E])>>Z;if(Z)b[B-G-1]^=(a[B]&p[Y]&q[E])<<(64-Z);}else{b[R-G]^=(a[R]&p[Y])>>Z;if(Z)b[R-G-1]^=(a[R]&p[Y])<<(64-Z);for(i=R-1;i>B;i--){b[i-G]^=a[i]>>Z;if(Z)b[i-G-1]^=a[i]<<(64-Z);}b[B-G]^=(a[B]&q[E])>>Z;if(Z)b[B-G-1]^=(a[B]&q[E])<<(64-Z);}}}
void bitOR(ull a[], ull b[], int stA, int stB, int len){int i,B,E,R,Y,X,G,Z;static ull p[65],q[65];static int f=0;if(!f){f=1;p[0]=0;rep(i,64)p[i+1]=(p[i]<<1)|1ULL;rep(i,65)q[i]=p[64]^p[i];}B=stA/64;E=stA%64;R=(stA+len)/64;Y=(stA+len)%64;X=stA-stB;G=X/64;Z=X%64;if(Z<0)Z+=64,G--;if(stA>stB){if(B==R){if(Z)b[B-G-1]|=(a[B]&p[Y]&q[E])<<(64-Z);b[B-G]|=(a[B]&p[Y]&q[E])>>Z;}else{if(Z)b[B-G-1]|=(a[B]&q[E])<<(64-Z);b[B-G]|=(a[B]&q[E])>>Z;REP(i,B+1,R){if(Z)b[i-G-1]|=a[i]<<(64-Z);b[i-G]|=a[i]>>Z;}if(Z)b[R-G-1]|=(a[R]&p[Y])<<(64-Z);b[R-G]|=(a[R]&p[Y])>>Z;}}else{if(B==R){b[B-G]|=(a[B]&p[Y]&q[E])>>Z;if(Z)b[B-G-1]|=(a[B]&p[Y]&q[E])<<(64-Z);}else{b[R-G]|=(a[R]&p[Y])>>Z;if(Z)b[R-G-1]|=(a[R]&p[Y])<<(64-Z);for(i=R-1;i>B;i--){b[i-G]|=a[i]>>Z;if(Z)b[i-G-1]|=a[i]<<(64-Z);}b[B-G]|=(a[B]&q[E])>>Z;if(Z)b[B-G-1]|=(a[B]&q[E])<<(64-Z);}}}

ll A[2000010], B[2000010];

int arr[2000001];
ull bit[100000];

int N, X, Y, Z, Q;
int S, T, U, V, L;
char mode[10];
char res[2000100];

int main(){
  int i, j, k;

  scanf("%d%d%d%d%d",&N,&S,&X,&Y,&Z);

  A[0] = S;
  REP(i,1,N) A[i] = (A[i-1] * X + Y) % Z;
  rep(i,N) if(A[i]%2) bit[i/64] |= (1ULL << (i%64));

  scanf("%d",&Q);
  while(Q--){
    scanf("%d%d%d%d",&S,&T,&U,&V);
    S--; U--; L = T-S;
    bitXOR(bit, bit, S, U, L);
  }

  res[N] = '\0';
  rep(i,N){
    if(bit[i/64]&(1ULL<<(i%64))){
      res[i] = 'O';
    } else {
      res[i] = 'E';
    }
  }
  puts(res);

  return 0;
}
0