当前位置:网站首页>1094 the largest generation (25 points)
1094 the largest generation (25 points)
2022-07-03 04:55:00 【vs5】
The main idea of the topic : Give a genealogical tree , The same layer is a generation , Ask for the largest generation , And which floor .
bfs,dfs Fine
#include <iostream>
#include <queue>
#include <unordered_map>
using namespace std;
vector<int>e[200];
unordered_map<int,int>mp,root;
int u,h,s;
void bfs()
{
queue<pair<int,int>>que;
que.push({u,1});
while(que.size())
{
auto t = que.front();que.pop();
int v = t.first,c = t.second;
mp[c] ++;
for(auto it : e[v])
{
que.push({it,c + 1});
}
}
}
int main()
{
int n,m;
cin >> n >> m;
while(m --)
{
int fa,cs,ch;
cin >> fa >> cs;
for(int i = 0; i < cs; i ++)
{
cin >> ch;
root[ch] = 1;
e[fa] .push_back(ch);
}
}
for(int i = 1; i <= n; i ++) if(!root.count(i)) u = i;
bfs();
for(auto it : mp)
{
if(it.second > s) s = it.second,h = it.first;
}
cout << s << ' ' << h << endl;
return 0;
}边栏推荐
- Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
- The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
- [research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
- Basic use of Metasploit penetration testing framework
- Market status and development prospect prediction of global neutral silicone sealant industry in 2022
- 雇佣收银员(差分约束)
- Compile and decompile GCC common instructions
- C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
- 普通本科大学生活避坑指南
- JDBC database operation
猜你喜欢

《牛客刷verilog》Part II Verilog进阶挑战

SSM framework integration

Leetcode simple question: the key with the longest key duration

Truncated sentences of leetcode simple questions

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)

The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
![[luatos sensor] 2 air pressure bmp180](/img/88/2a6caa5fec95e54e3fb09c74ba8ae6.jpg)
[luatos sensor] 2 air pressure bmp180

Basic use of Metasploit penetration testing framework

Number of uniform strings of leetcode simple problem

The reason why the entity class in the database is changed into hump naming
随机推荐
2022-02-12 daily clock in: problem fine brush
Leetcode simple problem delete an element to strictly increment the array
1119 pre- and post order traversals (30 points)
Market status and development prospect prediction of the near infrared sensor industry of the global Internet of things in 2022
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
Thesis reading_ Chinese medical model_ eHealth
Uipath practice (08) - selector
Learning record of arouter principle
MC Layer Target
Number of 1 in binary (simple difficulty)
普通本科大学生活避坑指南
SSM framework integration
[luatos sensor] 1 light sensing bh1750
Market status and development prospect forecast of global button dropper industry in 2022
Concurrent operation memory interaction
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Caijing 365 stock internal reference: what's the mystery behind the good father-in-law paying back 50 million?
M1 Pro install redis
112 stucked keyboard (20 points)
Notes | numpy-08 Advanced index