結果

問題 No.884 Eat and Add
ユーザー tailstails
提出日時 2021-12-24 17:36:10
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 580 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 29,372 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 20:13:43
合計ジャッジ時間 1,194 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 0 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'f1':
main.c:13:16: warning: implicit declaration of function 'read'; did you mean 'rd'? [-Wimplicit-function-declaration]
   13 |         long n=read(0,s,200001)-1;
      |                ^~~~
      |                rd
main.c: In function 'f2':
main.c:27:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   27 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:28:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   28 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

#define rd_skip() while(*rp++>=48)
#define rd_skip_line() while(*rp++!=10)
#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define wt(v) {ulong _z=v;do*--wp=_z%10+48;while(_z/=10);}

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

long f1(){
	long n=read(0,s,200001)-1;
	long r=0,c='0';
	while(--n){
		if(s[n]!=c){
			++r;
			c=s[n-1];
		}
	}
	return r+1;
}

void f2(long r){
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(r);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}

int main(){
	f2(f1());
	return 0;
}
0