結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー tailstails
提出日時 2023-05-24 17:29:24
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,475 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 29,524 KB
実行使用メモリ 5,908 KB
最終ジャッジ日時 2023-08-25 11:38:32
合計ジャッジ時間 9,163 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 58 ms
4,648 KB
testcase_02 AC 65 ms
4,996 KB
testcase_03 AC 61 ms
4,952 KB
testcase_04 AC 62 ms
4,980 KB
testcase_05 AC 63 ms
5,076 KB
testcase_06 AC 66 ms
5,660 KB
testcase_07 AC 67 ms
5,580 KB
testcase_08 AC 68 ms
5,644 KB
testcase_09 AC 69 ms
5,716 KB
testcase_10 AC 63 ms
4,972 KB
testcase_11 AC 66 ms
5,068 KB
testcase_12 AC 66 ms
5,008 KB
testcase_13 AC 66 ms
5,080 KB
testcase_14 AC 66 ms
5,008 KB
testcase_15 AC 67 ms
5,064 KB
testcase_16 AC 66 ms
5,016 KB
testcase_17 AC 66 ms
5,012 KB
testcase_18 AC 66 ms
5,096 KB
testcase_19 AC 66 ms
5,092 KB
testcase_20 AC 66 ms
5,004 KB
testcase_21 AC 73 ms
5,836 KB
testcase_22 AC 75 ms
5,864 KB
testcase_23 AC 76 ms
5,768 KB
testcase_24 AC 74 ms
5,840 KB
testcase_25 AC 74 ms
5,776 KB
testcase_26 AC 74 ms
5,824 KB
testcase_27 AC 74 ms
5,768 KB
testcase_28 AC 74 ms
5,904 KB
testcase_29 AC 74 ms
5,908 KB
testcase_30 AC 74 ms
5,764 KB
testcase_31 AC 24 ms
5,068 KB
testcase_32 AC 24 ms
5,004 KB
testcase_33 AC 24 ms
5,184 KB
testcase_34 AC 32 ms
5,524 KB
testcase_35 AC 32 ms
5,520 KB
testcase_36 AC 33 ms
5,568 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 66 ms
5,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:91:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wbuf,wp-wbuf);
  ^~~~~
main.c:92:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:92:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd_skip() while(*rp++>=48)
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)

typedef unsigned long ulong;

#define FWSIZE (1<<18)
int fw[FWSIZE];
int fwsize;
int fwlim;

static inline
void fw_add(int a,int v){
	if(a==0){
		fw[0]+=v;
	}else{
		while(fw[a]+=v,a+=a&-a,a<fwsize);
	}
}

void fw_build(){
	for(int a=1;a<fwlim-1;++a){
		fw[a+(a&-a)]+=fw[a];
	}
}

static inline
int fw_kth(int k){
	k-=fw[0];
	if(k<0)return 0;
	int a=0;
	for(int m=fwlim;m>>=1;){
		if(fw[a+m]<=k){
			k-=fw[a+m];
			a+=m;
		}
	}
	return a+1;
}

char wbuf[1<<25];
char x[1<<18],y[1<<18];

int main(){
	rd_init();
	rd_skip();
	char*wp=wbuf;
	while(*rp){
		int n=rd();
		fwsize=n;
		for(fwlim=1;fwlim<n;fwlim<<=1);
		rep(i,n)fw[i]=1;
		fw_build();
		rep(i,n){
			int c=*rp;
			if(c=='T'){
				rp+=5;
				x[i]=1;
			}else{
				rp+=6;
				x[i]=0;
			}
		}
		rep(i,n-1){
			int c=*rp;
			y[i+1]=c;
			rp+=c=='o'?3:4;
		}
		rep(i,n-1){
			int s=rd();
			int a=fw_kth(s-1);
			int b=fw_kth(s);
			fw_add(b,-1);
			if(y[b]=='a') x[a]&=x[b];
			if(y[b]=='o') x[a]|=x[b];
			if(y[b]=='x') x[a]^=x[b];
			if(y[b]=='i') x[a]=!x[a]|x[b];
		}
		if(x[0]){
			*(ulong*)wp=0x0a65757254l; // "True\n"
			wp+=5;
		}else{
			*(ulong*)wp=0x0a65736c6146l; // "False\n"
			wp+=6;
		}
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0