結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー tailstails
提出日時 2022-10-18 11:04:13
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 3,000 ms
コード長 993 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 25,624 KB
実行使用メモリ 11,496 KB
最終ジャッジ日時 2023-08-24 17:12:03
合計ジャッジ時間 6,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 15 ms
10,732 KB
testcase_03 AC 16 ms
10,872 KB
testcase_04 AC 15 ms
10,820 KB
testcase_05 AC 13 ms
10,648 KB
testcase_06 AC 15 ms
10,952 KB
testcase_07 AC 17 ms
10,636 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 15 ms
10,728 KB
testcase_10 AC 11 ms
10,096 KB
testcase_11 AC 11 ms
10,152 KB
testcase_12 AC 14 ms
10,624 KB
testcase_13 AC 17 ms
10,972 KB
testcase_14 AC 14 ms
10,836 KB
testcase_15 AC 17 ms
11,208 KB
testcase_16 AC 20 ms
11,296 KB
testcase_17 AC 15 ms
10,404 KB
testcase_18 AC 17 ms
10,824 KB
testcase_19 AC 12 ms
10,420 KB
testcase_20 AC 18 ms
11,004 KB
testcase_21 AC 6 ms
6,120 KB
testcase_22 AC 23 ms
11,432 KB
testcase_23 AC 23 ms
11,412 KB
testcase_24 AC 21 ms
11,432 KB
testcase_25 AC 21 ms
11,364 KB
testcase_26 AC 21 ms
11,368 KB
testcase_27 AC 21 ms
11,488 KB
testcase_28 AC 22 ms
11,368 KB
testcase_29 AC 22 ms
11,488 KB
testcase_30 AC 21 ms
11,476 KB
testcase_31 AC 22 ms
11,472 KB
testcase_32 AC 21 ms
11,408 KB
testcase_33 AC 23 ms
11,336 KB
testcase_34 AC 22 ms
11,400 KB
testcase_35 AC 21 ms
11,492 KB
testcase_36 AC 21 ms
11,496 KB
testcase_37 AC 22 ms
11,480 KB
testcase_38 AC 23 ms
11,492 KB
testcase_39 AC 21 ms
11,492 KB
testcase_40 AC 21 ms
11,344 KB
testcase_41 AC 22 ms
11,380 KB
testcase_42 AC 19 ms
11,012 KB
testcase_43 AC 20 ms
11,084 KB
testcase_44 AC 19 ms
11,088 KB
testcase_45 AC 18 ms
11,072 KB
testcase_46 AC 19 ms
11,052 KB
testcase_47 AC 18 ms
10,836 KB
testcase_48 AC 17 ms
10,776 KB
testcase_49 AC 19 ms
10,832 KB
testcase_50 AC 18 ms
10,764 KB
testcase_51 AC 18 ms
10,836 KB
testcase_52 AC 6 ms
4,384 KB
testcase_53 AC 5 ms
4,380 KB
testcase_54 AC 5 ms
4,384 KB
testcase_55 AC 9 ms
5,572 KB
testcase_56 AC 9 ms
5,552 KB
testcase_57 AC 9 ms
5,592 KB
testcase_58 AC 3 ms
4,384 KB
testcase_59 AC 21 ms
11,404 KB
testcase_60 AC 3 ms
4,388 KB
testcase_61 AC 9 ms
5,524 KB
testcase_62 AC 7 ms
7,640 KB
testcase_63 AC 3 ms
4,380 KB
testcase_64 AC 3 ms
4,380 KB
testcase_65 AC 6 ms
6,720 KB
testcase_66 AC 9 ms
5,616 KB
testcase_67 AC 3 ms
4,380 KB
testcase_68 AC 5 ms
5,592 KB
testcase_69 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:57:14: warning: multi-character character constant [-Wmultichar]
    *(int*)wp='\noN';
              ^~~~~~
main.c:62:14: warning: multi-character character constant [-Wmultichar]
    *(int*)wp='\nseY';
              ^~~~~~~
main.c:69:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wbuf,wp-wbuf);
  ^~~~~
main.c:70:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:70:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

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

#define rd_skip() while(*rp++>=48)

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

#define HASH_BITS 20
#define HASH_MASK ((1<<HASH_BITS)-1)
ulong hash[1<<HASH_BITS];

int main(){
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd_skip();
	char*wp=wbuf;
	while(*rp){
		ulong h=0;
		long c;
		while(c=*rp++,c!=10){
			h=h*27+c;
		}
		ulong aa=~0;
		{
			ulong a=h&HASH_MASK;
			while(1){
				if(hash[a]==h){
					goto yes;
				}
				if(hash[a]==0){
					aa=a;
					break;
				}
				a=a+1&HASH_MASK;
			}
		}
		char*p=rp-1;
		long b=*--p;
		ulong m=26;
		while(c=*--p,c!=10){
			ulong h2=h+(b-c)*m;
			ulong a=h2&HASH_MASK;
			while(1){
				if(hash[a]==h2){
					goto yes;
				}
				if(hash[a]==0){
					break;
				}
				a=a+1&HASH_MASK;
			}
			m*=27;
			b=c;
		}
		if(1){
			*(int*)wp='\noN';
			wp+=3;
		}
		if(0){
			yes:;
			*(int*)wp='\nseY';
			wp+=4;
		}
		if(~aa){
			hash[aa]=h;
		}
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0