結果

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

テストケース

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

ソースコード

diff #

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

char*mmap();
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

#define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;}
#define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;}
#define WT(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);}

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

int hash_add(long x){
	int h=x&(1<<HASH_BITS)-1;
	while(1){
		if(hash[h]==0){
			hash[h]=x;
			return 1;
		}
		if(hash[h]==x){
			return 0;
		}
		h=h+1&(1<<HASH_BITS)-1;
	}
}

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];
		z+=hash_add(s);
	}
	{
		long n=0,d=0;
		while(++n,d=d<<8|0x30|z%10,z/=10);
		write(1,&d,n);
	}
	_exit(0);
}


0