当前位置:网站首页>"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 5Input Example 1
2The 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 4Example output 2
0All 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();} 边栏推荐
猜你喜欢

基于FPGA的FIR滤波器的实现(1)—采用fir1函数设计

清华|GLM-130B:一个开放的双语预训练模型

Implementation of FIR filter based on FPGA (1) - using fir1 function design

idea增加左右箭头

Full of dry goods, Yu Jingxin class of the Institute of Information Technology, Chinese Academy of Sciences will help you get academic research and thesis writing skills

无头单向非循环链表(C语言实现)

剑指 Offer 66. 构建乘积数组

《预训练周刊》第56期:长文本理解、即时问答、掩码自监督

KMP Media Group South Africa implemented a DMS (Document Management System) to digitize the process, employees can again focus on their actual tasks, providing efficiency

南非 KMP 媒体集团实施了 DMS(文档管理系统)使流程数字化,员工可以再次专注于他们的实际任务,提供了效率
随机推荐
win32&mfc————win32菜单栏&库
Flink1.15源码阅读——StreamGraph流图
R语言数据类型转换:基本数据类型的转换、将一种数据类型转化为另外一种数据类型
Tsinghua | GLM-130B: An Open Bilingual Pre-training Model
itk中图像2d-3d配准整理
【索引】图神经论文之GCN(持更)
Review: What is the pre-approval of autumn recruitment?What is an ordinary autumn move?It's all recruitment, why do you need to set these two recruitment time periods?
serialize 序列化原生方法
serialize serialize native method
难产的“第一股”:中式快餐之困
window停掉指定端口的进程
qtwebapp库的编译及简单使用
【Rust—LeetCode题解】1.两数之和
Time to update your tech arsenal in 2020: Asgi vs Wsgi (FastAPI vs Flask)
代码随想录笔记_动态规划_322零钱兑换
R语言基于指定规则、条件删除列表中的元素:使用purrr包的discard函数移除列表数据中的NA值
全网最全的AItium Designer 16下载资源与安装步骤
Implement a customized pin code input control
删库不易,跑路更难
【LeetCode】761. 特殊的二进制序列