結果

問題 No.2047 Path Factory
ユーザー tailstails
提出日時 2022-12-01 16:05:49
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 28,640 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-04-17 05:53:14
合計ジャッジ時間 1,378 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 0 ms
6,944 KB
testcase_03 AC 0 ms
6,940 KB
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 0 ms
6,940 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 4 ms
6,944 KB
testcase_15 AC 5 ms
6,944 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 4 ms
6,940 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 6 ms
6,940 KB
testcase_20 AC 9 ms
6,948 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 8 ms
9,216 KB
testcase_26 AC 11 ms
7,936 KB
testcase_27 AC 6 ms
6,944 KB
testcase_28 AC 4 ms
6,940 KB
testcase_29 AC 0 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:54:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
   54 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:55:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   55 |         _exit(0);
      |         ^~~~~
main.c:55:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

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

#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define rep(v,e) for(long v=0;v<e;++v)
#define rep3(v,s,e) for(long v=s;v<e;++v)
#define aaa(x) ({ulong r=x;r-(r<MD?0:MD);})
#define MD 998244353

typedef unsigned long ulong;

#define MAXN 100000
int en[MAXN+2];
int eb[MAXN<<1];
int uv[MAXN<<1];

ulong f(long i,long p){
	ulong a=1,b=0,c=0;
	rep3(k,en[i],en[i+1]){
		long j=eb[k];
		if(j!=p){
			ulong s=f(j,i);
			ulong y=s>>32;
			ulong x=(unsigned)s;
			c=(c*y+b*x)%MD;
			b=(b*y+a*x)%MD;
			a=a*y%MD;
		}
	}
//	return aaa(a+b)|aaa(b+c)<<32;
	return (a+b)|(b+c)<<32;
}

int main(){
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	long n=rd();
	rep(j,n-1<<1){
		++en[(uv[j]=rd()-1)+2];
	}
	{
		int s=0;
		rep3(i,2,n+2){
			en[i]=s+=en[i];
		}
	}
	rep(j,n-1<<1){
		eb[en[uv[j]+1]++]=uv[j^1];
	}
	ulong s=f(0,0);
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(aaa(s>>32));
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0