結果

問題 No.1553 Lovely City
ユーザー tailstails
提出日時 2021-06-18 21:57:48
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 4,123 ms
コンパイル使用メモリ 182,664 KB
実行使用メモリ 33,268 KB
最終ジャッジ日時 2023-09-19 02:26:32
合計ジャッジ時間 12,561 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 26 ms
21,768 KB
testcase_03 RE -
testcase_04 AC 1 ms
4,384 KB
testcase_05 RE -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

{
	VI resu,resv;

	graph g;
	int @n,@m;
	VI u(m),v(m);
	rd((u,v)(m));
	g.setDirectEdge(n+1,m,u.data(),v.data());
	VI ss(n);
	int sn=g.scc(ss.data());
//	VVI vvi(sn);
	vector<VI> vvi(sn);
	rep(i,1,n+1){
		vvi[ss[i]].push_back(i);
	}
	rep(j,sn){
		int n=vvi[j].size();
		if(n>1){
			rep(k,n-1){
				resu.push_back(vvi[j][k]);
				resv.push_back(vvi[j][k+1]);
			}
			resu.push_back(vvi[j][n-1]);
			resv.push_back(vvi[j][0]);
		}
	}
	unionFind uf;
	uf.walloc(n+1,1);
	rep(i,m){
		int su=ss[u[i]];
		int sv=ss[v[i]];
		if(uf(su,sv)){
			resu.push_back(vvi[su][0]);
			resv.push_back(vvi[sv][0]);
		}
	}
	wt(int(resu.size()));
	rep(i,resu.size()){
		wt(resu[i],resv[i]);
	}
}
0