代码

Jerry_Zhou · 发布于 2021-10-30 · 浏览 724 回复 0
#include<bits/stdc++.h>
using namespace std;

int n,a[105][105],stk[105],m[105],k,top;
int main(){
    cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	stk[++top]=1;
	m[1]=1;
	cout<<1;
	while(top>0){
		k++;
		if(k>n) k=stk[top--];
		else if(a[stk[top]][k]&&!m[k]){
			cout<<"-"<<k;
			stk[++top]=k;
			m[k]=1;
			k=0;
		}
	}
	cout<<endl;
	//system("pause");
	return 0;
} 

全部回复 共 0 条

还没有人回复。往下写第一条。

发表回复