文章
99
粉丝
120
获赞
8
访问
97.5k
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const int maxn = 26;
vector<int> g[maxn];
int n, m, depth;
string s;
void print(int d, int flag) { //打印,flag表示是 0表示长辈,1表示孩子,d表示深度depth
if (d == 1) {
cout << (flag == 0 ? "parent" : "child") << endl;
}
else if (d == 2) {
cout << (flag == 0 ? "grandparent" : "grandchild") << endl;
}
else {
for (int i = 0; i < d - 2; i++) {
cout << "great-";
}
cout << (flag == 0 ? "grandparent" : "grandchild") << endl;
}
}
void dfs(int f, int t, int d) { //from to depth
if (f == t) {
depth = d;
return;
}
for (int i = 0; i < g[f].size(); i++) {
dfs(g[f][i], t, d + 1);
}
}
int main() {
while (cin >> n >> m) {
for (int i = 0; i < n; i++) {
cin >> s;
if (...
登录后发布评论
暂无评论,来抢沙发