結果

問題 No.1891 Static Xor Range Composite Query
ユーザー tailstails
提出日時 2022-04-04 20:31:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 1,647 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 35,740 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2023-08-16 22:31:00
合計ジャッジ時間 5,484 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
40,456 KB
testcase_01 AC 22 ms
40,488 KB
testcase_02 AC 23 ms
40,460 KB
testcase_03 AC 23 ms
40,360 KB
testcase_04 AC 23 ms
40,504 KB
testcase_05 AC 23 ms
40,512 KB
testcase_06 AC 23 ms
40,360 KB
testcase_07 AC 23 ms
40,420 KB
testcase_08 AC 23 ms
40,556 KB
testcase_09 AC 22 ms
40,428 KB
testcase_10 AC 22 ms
40,480 KB
testcase_11 AC 22 ms
40,464 KB
testcase_12 AC 23 ms
40,512 KB
testcase_13 AC 22 ms
40,524 KB
testcase_14 AC 22 ms
40,600 KB
testcase_15 AC 23 ms
40,464 KB
testcase_16 AC 23 ms
40,556 KB
testcase_17 AC 22 ms
40,500 KB
testcase_18 AC 23 ms
40,572 KB
testcase_19 AC 22 ms
40,460 KB
testcase_20 AC 23 ms
40,596 KB
testcase_21 AC 140 ms
56,232 KB
testcase_22 AC 144 ms
56,136 KB
testcase_23 AC 143 ms
56,056 KB
testcase_24 AC 143 ms
56,152 KB
testcase_25 AC 143 ms
56,052 KB
testcase_26 AC 153 ms
56,160 KB
testcase_27 AC 153 ms
56,192 KB
testcase_28 AC 142 ms
56,260 KB
testcase_29 AC 145 ms
56,152 KB
testcase_30 AC 147 ms
56,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘mkwd’ 内:
main.c:12:20: 警告: 複数文字からなる文字定数 [-Wmultichar]
   12 |         unsigned v='0000';
      |                    ^~~~~~
main.c: 関数 ‘main’ 内:
main.c:102:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
  102 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:103:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
  103 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd_skip() while(*rp++>=48)
#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(long v=0;v<e;++v)

unsigned wd[10000];
char wdlen[10000];

void mkwd(){
	unsigned v='0000';
	long i=0;
	rep(a,10){
		rep(b,10){
			rep(c,10){
				rep(d,10){
					wd[i++]=v;
					v+=1<<24;
				}
				v+=(1<<16)-(10<<24);
			}
			v+=(1<<8)-(10<<16);
		}
		v+=(1<<0)-(10<<8);
	}
	rep(j,10000) wdlen[j]=4;
	rep(j,1000) wdlen[j]=3;
	rep(j,100) wdlen[j]=2;
	rep(j,10) wdlen[j]=1;
}

typedef unsigned long ulong;
char wbuf[1<<25];

#define MD 998244353

struct AB {
	unsigned a,b;
};

#define F(r,x,y) ({ulong a=(ulong)y.a*(ulong)x.a,b=(ulong)y.a*(ulong)x.b+(ulong)y.b;r.a=a%MD;r.b=b%MD;})

struct AB ab[19][262144];
unsigned z[200000];

int main(){
	mkwd();

	long n;
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	n=rd();
	rd_skip();
	rep(i,n){
		ab[0][i].a=rd();
		ab[0][i].b=rd();
	}
	rep(d,18){
		ulong m=1<<d;
		rep(i,262144){
			F(ab[d+1][i],ab[d][i],ab[d][i^m]);
		}
	}
	long q=0;
	char*wp=wbuf+sizeof wbuf;
	while(*rp){
		long l=rd();
		long r=rd();
		ulong p=rd();
		long x=rd();
		struct AB u; u.a=1; u.b=0;
		struct AB v; v.a=1; v.b=0;
		long d=0;
		while(l<r){
			ulong m=1<<d;
			if(l&m){
				F(u,u,ab[d][l^p]);
				l+=m;
			}
			if(r&m){
				r-=m;
				F(v,ab[d][r^p],v);
			}
			++d;
		}
		F(u,u,v);
		z[q++]=(u.a*x+u.b)%MD;
	}
	while(q--){
		*--wp='\n';
		unsigned v=z[q];
		while(v>=10000){
			wp-=4;
			*(unsigned*)wp=wd[v%10000];
			v/=10000;
		}
		wp-=4;
		*(unsigned*)wp=wd[v];
		wp+=4-wdlen[v];
	}
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0