結果

問題 No.2427 Tree Distance Two
ユーザー tailstails
提出日時 2023-08-21 13:29:49
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 26,376 KB
実行使用メモリ 13,356 KB
最終ジャッジ日時 2023-08-21 13:29:53
合計ジャッジ時間 4,697 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,576 KB
testcase_01 AC 1 ms
5,636 KB
testcase_02 AC 1 ms
5,616 KB
testcase_03 AC 20 ms
13,332 KB
testcase_04 AC 1 ms
5,656 KB
testcase_05 AC 21 ms
13,256 KB
testcase_06 AC 1 ms
5,604 KB
testcase_07 AC 18 ms
13,348 KB
testcase_08 AC 18 ms
13,276 KB
testcase_09 AC 18 ms
13,124 KB
testcase_10 AC 18 ms
13,216 KB
testcase_11 AC 19 ms
13,356 KB
testcase_12 AC 21 ms
13,292 KB
testcase_13 AC 22 ms
13,212 KB
testcase_14 AC 10 ms
13,216 KB
testcase_15 AC 2 ms
5,520 KB
testcase_16 AC 1 ms
5,608 KB
testcase_17 AC 1 ms
5,504 KB
testcase_18 AC 1 ms
5,556 KB
testcase_19 AC 1 ms
5,664 KB
testcase_20 AC 2 ms
7,768 KB
testcase_21 AC 2 ms
7,760 KB
testcase_22 AC 2 ms
7,700 KB
testcase_23 AC 2 ms
5,680 KB
testcase_24 AC 2 ms
7,756 KB
testcase_25 AC 5 ms
8,812 KB
testcase_26 AC 12 ms
10,604 KB
testcase_27 AC 8 ms
9,792 KB
testcase_28 AC 18 ms
12,716 KB
testcase_29 AC 16 ms
11,868 KB
testcase_30 AC 12 ms
10,556 KB
testcase_31 AC 7 ms
9,392 KB
testcase_32 AC 12 ms
10,548 KB
testcase_33 AC 10 ms
10,168 KB
testcase_34 AC 4 ms
8,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:43:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wp,wbuf+sizeof wbuf-wp);
  ^~~~~
main.c:44:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:44:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#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(typeof(e) v=0;v<e;++v)
#define rrep(v,e) for(typeof(e) v=e;v--;)
#define rrep3(v,s,e) for(typeof(e) v=e;--v>=s;)

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

char wbuf[1<<25];

int main(){
	rd_init();
	long n=rd();
	rep(j,n-1<<1){
		++en[uv[j]=rd()-1];
	}
	{
		int s=0;
		rep(i,n+1){
			en[i]=s+=en[i];
		}
	}
	rrep(j,n-1<<1){
		eb[--en[uv[j]]]=uv[j^1];
	}
	char*wp=wbuf+sizeof wbuf;
	rrep(i,n){
		int z=0;
		rrep3(k,en[i],en[i+1]){
			long j=eb[k];
			z+=en[j+1]-en[j]-1;
		}
		*--wp='\n';
		wt(z);
	}
	write(1,wp,wbuf+sizeof wbuf-wp);	
	_exit(0);
}
0