比赛 |
2024暑假C班集训E |
评测结果 |
EEEEEEEEEE |
题目名称 |
灾难 |
最终得分 |
0 |
用户昵称 |
ht骨架 |
运行时间 |
2.325 s |
代码语言 |
C++ |
内存使用 |
3.88 MiB |
提交时间 |
2024-07-14 11:50:51 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> a[10005];
vector <int> c[10005];
int dfs (int i, int ans) {
if (ans == n) return ans;
if (c[i][0] == 1) dfs(c[i][1], ans + 1);
else return ans;
}
int main () {
freopen ("catas.in", "r", stdin);
freopen ("catas.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++) {
a[i].push_back(0);
while (1) {
a[i][0]++;
int x;
cin >> x;
c[x].push_back(0);
c[x][0]++;
if(x==0){
break;
}
a[i].push_back(x);
c[x][c[x][0]] = i;
cout << a[i][a[i][0]] << endl << c[x][c[x][0]] << endl;
}
}
for (int i = 1; i <= n; i++) {
cout << dfs(i, 0) << endl;
}
return 0;
}