結果

問題 No.1292 パタパタ三角形
ユーザー tailstails
提出日時 2020-11-24 00:19:48
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 29,372 KB
実行使用メモリ 9,948 KB
最終ジャッジ日時 2023-10-01 00:37:25
合計ジャッジ時間 1,037 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 9 ms
7,228 KB
testcase_08 AC 7 ms
6,176 KB
testcase_09 AC 12 ms
9,768 KB
testcase_10 AC 12 ms
9,776 KB
testcase_11 AC 12 ms
9,948 KB
testcase_12 AC 13 ms
9,832 KB
testcase_13 AC 7 ms
6,452 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:8:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
    8 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:9:15: 警告: 関数 ‘read’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    9 |         int n=read(0,rbuf+1,(sizeof rbuf)-1);
      |               ^~~~
main.c:38:17: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   38 |                 write(1,&d,n);
      |                 ^~~~~
main.c:40:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   40 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

#define HASH_BITS 20
long hash[1<<HASH_BITS];

char rbuf[200004];
main(){
	int n=read(0,rbuf+1,(sizeof rbuf)-1);
	rbuf[n]=0;
	rbuf[0]=97;
	char*rp=rbuf;
	long x[100];
	x[97]=0;
	x[98]=1;
	x[99]=1e9+7;
	long s=0;
	int z=0;
	for(int c;c=*rp++,c;){
		x[c]=s-x[c]*2;
		s=x[97]+x[98]+x[99];
		int h=s&(1<<HASH_BITS)-1;
		while(1){
			if(hash[h]==0){
				hash[h]=s;
				++z;
				break;
			}
			if(hash[h]==s){
				break;
			}
			h=h+1&(1<<HASH_BITS)-1;
		}
	}
	{
		long n=0,d=0;
		while(++n,d=d<<8|0x30|z%10,z/=10);
		write(1,&d,n);
	}
	_exit(0);
}
0