結果

問題 No.2047 Path Factory
ユーザー tails
提出日時 2022-12-01 16:05:49
言語 C90
(gcc 12.3.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,060 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 27,008 KB
最終ジャッジ日時 2025-01-24 13:49:52
合計ジャッジ時間 3,512 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'f':
main.c:7:21: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    7 | #define rep3(v,s,e) for(long v=s;v<e;++v)
      |                     ^~~
main.c:20:9: note: in expansion of macro 'rep3'
   20 |         rep3(k,en[i],en[i+1]){
      |         ^~~~
main.c:7:21: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
    7 | #define rep3(v,s,e) for(long v=s;v<e;++v)
      |                     ^~~
main.c:20:9: note: in expansion of macro 'rep3'
   20 |         rep3(k,en[i],en[i+1]){
      |         ^~~~
main.c:31:1: error: C++ style comments are not allowed in ISO C90
   31 | //      return aaa(a+b)|aaa(b+c)<<32;
      | ^
main.c:31:1: note: (this will be reported only once per input file)
main.c: In function 'main':
main.c:6:18: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    6 | #define rep(v,e) for(long v=0;v<e;++v)
      |                  ^~~
main.c:39:9: note: in expansion of macro 'rep'
   39 |         rep(j,n-1<<1){
      |         ^~~
main.c:7:21: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    7 | #define rep3(v,s,e) for(long v=s;v<e;++v)
      |                     ^~~
main.c:44:17: note: in expansion of macro 'rep3'
   44 |                 rep3(i,2,n+2){
      |                 ^~~~
main.c:48:13: error: redefinition of 'j'
   48 |         rep(j,n-1<<1){
      |             ^
main.c:6:27: note: in definition of macro 'rep'
    6 | #define rep(v,e) for(long v=0;v<e;++v)
      |                           ^
main.c:39:13: note: previous definition of 'j' with type 'long int'
   39 |         rep(j,n-1<<1){
      |             ^
main.c:6:27: note: in definition of macro 'rep'
    6 | #define rep(v,e) for(long v=0;v<e;++v)
      |                           ^
main.c:6:18: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    6 | #define rep(v,e) for(long v=0;v<e;++v)
      |                 

ソースコード

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