提出 #39143794


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<int>>G(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		x--,y--;
		G[x].push_back(y);
	}
	
	vector<int>length(n,-1);
	auto dfs=[&](int v,auto dfs){
		if(length[v]!=-1)return length[v];
		length[v]=0;
		for(auto vv:G[v])length[v]=max(length[v],dfs(vv,dfs)+1);
		return length[v];
	};
	
	int d=0;
	for(int i=0;i<n;i++)d=max(d,dfs(i,dfs));
	if(d==n-1){
		cout << "Yes" << endl;
		for(auto x:length)cout << n-x << ' ';
	}else{
		cout << "No" << endl;
	}
}

提出情報

提出日時
問題 E - Find Permutation
ユーザ kyopro_friends
言語 C++ (GCC 9.2.1)
得点 500
コード長 586 Byte
結果 AC
実行時間 172 ms
メモリ 29696 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 39
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 6 ms 3484 KiB
hand_02.txt AC 2 ms 3480 KiB
hand_03.txt AC 2 ms 3624 KiB
hand_04.txt AC 2 ms 3464 KiB
random_01.txt AC 74 ms 8900 KiB
random_02.txt AC 52 ms 4076 KiB
random_03.txt AC 88 ms 6624 KiB
random_04.txt AC 21 ms 3776 KiB
random_05.txt AC 172 ms 29696 KiB
random_06.txt AC 77 ms 12164 KiB
random_07.txt AC 157 ms 20088 KiB
random_08.txt AC 131 ms 11272 KiB
random_09.txt AC 169 ms 23128 KiB
random_10.txt AC 57 ms 4832 KiB
random_11.txt AC 166 ms 21880 KiB
random_12.txt AC 149 ms 15384 KiB
random_13.txt AC 171 ms 27008 KiB
random_14.txt AC 128 ms 11592 KiB
random_15.txt AC 161 ms 24040 KiB
random_16.txt AC 131 ms 13692 KiB
random_17.txt AC 166 ms 27612 KiB
random_18.txt AC 56 ms 7104 KiB
random_19.txt AC 171 ms 22984 KiB
random_20.txt AC 64 ms 4588 KiB
random_21.txt AC 39 ms 4168 KiB
random_22.txt AC 145 ms 24048 KiB
random_23.txt AC 18 ms 4596 KiB
random_24.txt AC 2 ms 3616 KiB
random_25.txt AC 108 ms 7848 KiB
random_26.txt AC 51 ms 4136 KiB
random_27.txt AC 92 ms 8692 KiB
random_28.txt AC 21 ms 3968 KiB
random_29.txt AC 116 ms 12036 KiB
random_30.txt AC 37 ms 4076 KiB
random_31.txt AC 19 ms 3836 KiB
random_32.txt AC 2 ms 3408 KiB
sample_01.txt AC 2 ms 3616 KiB
sample_02.txt AC 2 ms 3480 KiB
sample_03.txt AC 2 ms 3484 KiB