B开头的是啥题?
by xindubawukong @ 2022-08-05 17:44:41
人家就是不开呗,有什么大惊小怪的?
by sto_yyrdxh_orz @ 2022-08-05 17:45:03
@[wangyi_c](/user/560044) 洛谷网校的题目
by SegTree @ 2022-08-05 17:46:02
OK,thx
by wangyi_c @ 2022-08-05 17:47:38
@[xindubawukong](/user/420306) 入门与面试
by wangyi_c @ 2022-08-05 17:47:51
@[管理员](/user/365969)
by wangyi_c @ 2022-08-05 17:48:05
@[wangyi_c](/user/560044) 找 ShanCreeper 的博客里面一篇声明。
by irris @ 2022-08-05 17:54:09
毕竟写这部分题目的题解都是氪金用户才享有的权益,
by SegTree @ 2022-08-05 18:54:44
```cpp
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main()
{
int n;cin>>n;
vector<int> cnt(n+1,0),rcd[n+1];
for(int i=1;i<=n;i++)
{
int a;cin>>a;
while(a!=0)
{
rcd[i].push_back(a);
cnt[a]++;
cin>>a;
}
}
queue<int> q;
for(int i=1;i<=n;i++)
{
if(cnt[i]==0)
{
q.push(i);
cout<<i<<" ";
}
}
while(!q.empty())
{
int now=q.front();q.pop();
for(int i=0;i<(int)rcd[now].size();i++)
{
cnt[rcd[now][i]]--;
if(cnt[rcd[now][i]]==0)
{
q.push(rcd[now][i]);
cout<<rcd[now][i]<<" ";
}
}
}
return 0;
}
```
我在这贴一个完整的cpp题解,合情合理吧
by zqc2022 @ 2022-10-21 17:09:57
~~tlqtj,jbl~~(((
by BLuemoon_ @ 2023-07-09 10:33:15