当前位置:网站首页>"Small yards artisan study room" friends of friends is not a friend
"Small yards artisan study room" friends of friends is not a friend
2022-08-08 14:01:00 【Small yards artisan】
Labels
- Graph, undirected graph
topic address
Q4. AUO of AUO
- https://algo-method.com/tasks/413
Problem Description
Enter
Output
Output results
Input Example 1
6 7 00 10 51 31 5twenty three3 44 5
Input Example 1
2
The relationship between the six types of friends is shown in the figure below.
The friends of Arles are students 1 and 5, and the friends of friends of Arles are students 3 and 4.Since Arles has two "friends of friends", we will output 2.
Input Example 2
5 7 20 20 31 21 4twenty threetwenty four3 4
Example output 2
0
All students in Arles and the school are friends, so friends of friends are: 0
Solution
Small Coder Problem Solving
#include using namespace std;#define endl '\n';void coder_solution();int main() {// small coderscoder_solution();// returnreturn 0;}void coder_solution() {// Improve the efficiency of cin and coutios::sync_with_stdio(false);cin.tie(0);cout.tie(0);// Improve the efficiency of cin and coutios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n, m, x, a, b;cin >> n >> m >> x;vector> c(n);for(int i = 0; i < m; ++i) {cin >> a >> b;c[a].push_back(b);c[b].push_back(a);}unordered_set ans;set f;for(auto i : c[x]) {f.insert(i);}for(auto i : c[x]) {for (auto j : c[i]) {if (!f.count(j) && j != x) {ans.insert(j);}}}cout << ans.size();}
边栏推荐
猜你喜欢
pip install xxx 出现 AttributeError: ‘tuple’ object has no attribute ‘read’ 错误
译文推荐|深入解析 BookKeeper 协议模型与验证
小白大白读论文-关于EfficientNetV2论文的 疑问 与 总结
HackTheBox | Horizontall
腾讯,投了个 “离诺贝尔奖最近的华人”
剑指 Offer 66. 构建乘积数组
无头单向非循环链表(C语言实现)
全网最全的AItium Designer 16下载资源与安装步骤
【Rust—LeetCode题解】1.两数之和
OpenInfra Days China 2022 |StreamNative 翟佳、刘德志受邀分享
随机推荐
Code Casual Recording Notes_Dynamic Programming_322 Change Exchange
flink知识
【LeetCode】761. 特殊的二进制序列
Experience Sharing | Systematic Design and Development of Business Cache
全网最全的AItium Designer 16下载资源与安装步骤
「复盘」面试BAMT回来整理398道高频面试题,助你拿高薪offer
idea增加左右箭头
【小码匠自习室】ABC084 - D:喜欢这样的大神,超有才华
LeetCode 每日一题 2022/8/1-2022/8/7
textarea 禁止拖拽
UnsatisfiedDependencyException: Error creating bean with name ‘
哈佛大学砸场子:DALL-E 2只是「粘合怪」,生成正确率只有22%
6. [opencv mouse callback event]
初窥门径代码起手,Go lang1.18入门精炼教程,由白丁入鸿儒,首次运行golang程序EP01
清华|GLM-130B:一个开放的双语预训练模型
QWebAssembly中文适配
【小码匠自习室】[NOI Online 2020-3 入门组] 最急救助:被“幸运女神”眷顾的人
【小码匠自习室】ABC179-C:代码竟然没排倒数堪称一大奇迹
itk中生成drr整理
变量和函数的声明提前