結果

問題 No.2316 Freight Train
ユーザー tailstails
提出日時 2023-05-27 01:45:56
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 1,295 ms
コンパイル使用メモリ 25,712 KB
実行使用メモリ 6,900 KB
最終ジャッジ日時 2023-08-26 15:10:40
合計ジャッジ時間 4,534 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 11 ms
6,716 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 6 ms
4,968 KB
testcase_08 AC 7 ms
5,180 KB
testcase_09 AC 7 ms
5,252 KB
testcase_10 AC 6 ms
5,068 KB
testcase_11 AC 8 ms
5,416 KB
testcase_12 AC 10 ms
5,952 KB
testcase_13 AC 11 ms
6,732 KB
testcase_14 AC 12 ms
6,788 KB
testcase_15 AC 12 ms
6,820 KB
testcase_16 AC 11 ms
6,880 KB
testcase_17 AC 12 ms
6,872 KB
testcase_18 AC 11 ms
6,844 KB
testcase_19 AC 11 ms
6,788 KB
testcase_20 AC 11 ms
6,792 KB
testcase_21 AC 11 ms
6,792 KB
testcase_22 AC 11 ms
6,824 KB
testcase_23 AC 5 ms
6,040 KB
testcase_24 AC 7 ms
6,744 KB
testcase_25 AC 7 ms
6,840 KB
testcase_26 AC 5 ms
6,900 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:41:10: warning: multi-character character constant [-Wmultichar]
    *wp++='\nseY';
          ^~~~~~~
main.c:43:10: warning: multi-character character constant [-Wmultichar]
    *wp++='\n oN';
          ^~~~~~~
main.c:46:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wbuf,(wp-wbuf)*sizeof*wbuf);
  ^~~~~
main.c:47:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:47: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_skip() while(*rp++>=48)
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define rep3(v,s,e) for(typeof(e) v=s;v<e;++v)

int u[200004];
int r[200004];
int rn;
unsigned wbuf[1<<20];

int main(){
	rd_init();
	int n=rd();
	rd_skip();
	rep3(i,1,n+1){
		if(*rp=='-'){
			rp+=3;
			r[rn++]=i;
		}else{
			int p=rd();
			u[p]=i;
		}
	}
	while(rn){
		int b=r[--rn];
		for(int a=b;a;){
			int t=u[a];
			u[a]=b;
			a=t;
		}
	}
	unsigned*wp=wbuf;
	while(*rp){
		int a=rd();
		int b=rd();
		if(u[a]==u[b]){
			*wp++='\nseY';
		}else{
			*wp++='\n oN';
		}
	}
	write(1,wbuf,(wp-wbuf)*sizeof*wbuf);
	_exit(0);
}
0