結果

問題 No.1424 Ultrapalindrome
コンテスト
ユーザー 👑 tails
提出日時 2021-03-12 22:13:01
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,000 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 144 ms
コンパイル使用メモリ 28,452 KB
最終ジャッジ日時 2026-02-22 06:57:30
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:8:1: warning: data definition has no type or storage class
    8 | en[MAXN+1];
      | ^~
main.c:8:1: error: type defaults to 'int' in declaration of 'en' [-Wimplicit-int]
main.c:9:1: warning: data definition has no type or storage class
    9 | ei[MAXN+1];
      | ^~
main.c:9:1: error: type defaults to 'int' in declaration of 'ei' [-Wimplicit-int]
main.c:10:1: warning: data definition has no type or storage class
   10 | eb[MAXN<<1];
      | ^~
main.c:10:1: error: type defaults to 'int' in declaration of 'eb' [-Wimplicit-int]
main.c:11:1: warning: data definition has no type or storage class
   11 | uv[MAXN<<1];
      | ^~
main.c:11:1: error: type defaults to 'int' in declaration of 'uv' [-Wimplicit-int]
main.c:13:1: warning: data definition has no type or storage class
   13 | c[100000];
      | ^
main.c:13:1: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
main.c:25:1: error: return type defaults to 'int' [-Wimplicit-int]
   25 | main(){
      | ^~~~
main.c: In function 'main':
main.c:26:17: error: too many arguments to function 'mmap'; expected 0, have 6
   26 |         char*rp=mmap(0l,1l<<28,1,2,0,0ll);
      |                 ^~~~ ~~
main.c:4:6: note: declared here
    4 | char*mmap();
      |      ^~~~
main.c:61:41: error: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   61 |                                         write(1,"No",2);
      |                                         ^~~~~
main.c:62:41: error: implicit declaration of function '_exit' [-Wimplicit-function-declaration]
   62 |                                         _exit(0);
      |                                         ^~~~~
main.c:62:41: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]
main.c:71:33: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]
   71 |                                 _exit(0);
      |                         

ソースコード

diff #
raw source code

#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 MAXN 200000
en[MAXN+1];
ei[MAXN+1];
eb[MAXN<<1];
uv[MAXN<<1];

c[100000];

void f(int i,int p,int d){
	c[i]=d;
	for(int k=0;k<en[i];++k){
		int j=eb[ei[i]+k];
		if(j!=p){
			f(j,i,d+1);
		}
	}
}

main(){
	char*rp=mmap(0l,1l<<28,1,2,0,0ll);
	RD(n);
	{
		int ne=n-1<<1;
		for(int j=0;j<ne;++j){
			RD(t);
			uv[j]=t;
			++en[uv[j]];
		}
	}
	{
		int s=0;
		for(int i=0;++i<=n;){
			ei[i]=s;
			s+=en[i];
			en[i]=0;
		}
	}
	{
		int ne=n-1<<1;
		for(int j=0;j<ne;++j){
			int i=uv[j];
			eb[ei[i]+en[i]++]=uv[j^1];
		}
	}
	int r=1;
	while(en[r]!=1)++r;
	f(r,r,0);
	int e=0;
	for(int i=r+1;i<=n;++i){
		if(en[i]==1){
			if(e==0){
				e=c[i];
			}else{
				if(c[i]!=e){
					write(1,"No",2);
					_exit(0);
				}
			}
		}
	}
	for(int i=0;i<n;++i){
		if(en[i]>2){
			if(c[i]*2!=e){
				write(1,"No",2);
				_exit(0);
			}
		}
	}
	write(1,"Yes",3);
	_exit(0);
}
0