結果
問題 | No.142 単なる配列の操作に関する実装問題 |
ユーザー | LayCurse |
提出日時 | 2015-02-02 03:12:13 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 750 ms / 5,000 ms |
コード長 | 2,393 bytes |
コンパイル時間 | 1,973 ms |
コンパイル使用メモリ | 160,160 KB |
実行使用メモリ | 21,376 KB |
最終ジャッジ日時 | 2024-06-23 06:31:44 |
合計ジャッジ時間 | 5,333 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 210 ms
21,248 KB |
testcase_01 | AC | 614 ms
21,248 KB |
testcase_02 | AC | 750 ms
21,248 KB |
testcase_03 | AC | 203 ms
21,248 KB |
testcase_04 | AC | 600 ms
21,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d%d%d%d%d",&N,&S,&X,&Y,&Z); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:32:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d",&Q); | ~~~~~^~~~~~~~~ main.cpp:34:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d%d%d%d",&S,&T,&U,&V); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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; }