当前位置: 首页 > news >正文

常见的网站首页布局长沙seo结算

常见的网站首页布局,长沙seo结算,上海热线官网首页,wordpress兼容ieMr. Kitayuta’s Colorful Graph 题面翻译 给出一个 n n n 个点, m m m 条边的无向图,每条边上是有颜色的。有 q q q 组询问 对于第 i i i 组询问,给出点对 u i , v i u_i,v_i ui​,vi​。求有多少种颜色 c c c 满足:有至…

Mr. Kitayuta’s Colorful Graph

题面翻译

给出一个 n n n 个点, m m m 条边的无向图,每条边上是有颜色的。有 q q q 组询问

对于第 i i i 组询问,给出点对 u i , v i u_i,v_i ui,vi。求有多少种颜色 c c c 满足:有至少一条 u i u_i ui v i v_i vi 路径,满足该路径上的所有边的颜色都为 c c c

输入格式

第一行两个整数 n , m n,m n,m 分别表示点的个数和边的个数
接下来 m m m 行,每行三个整数 x i , y i , c i x_i,y_i,c_i xi,yi,ci,表示有一条连接点 x i , y i x_i,y_i xi,yi 的边,且该边的颜色为 c i c_i ci

接下来一行一个整数 q q q,表示询问的个数

接下来 q q q 行,每行两个整数 u i , v i u_i,v_i ui,vi,表示一组询问

输出格式

对于每一组询问,在单独的一行输出一个整数,表示满足上述要求的颜色种数

说明与提示

2 ≤ n ≤ 100 2 \le n \le 100 2n100
1 ≤ m , q ≤ 100 1 \le m,q \le 100 1m,q100
1 ≤ x i , y i , u i , v i ≤ n 1\le x_i,y_i,u_i,v_i \le n 1xi,yi,ui,vin
1 ≤ c i ≤ m 1 \le c_i \le m 1cim
感谢 @_Wolverine 提供的翻译

题目描述

Mr. Kitayuta has just bought an undirected graph consisting of $ n $ vertices and $ m $ edges. The vertices of the graph are numbered from 1 to $ n $ . Each edge, namely edge $ i $ , has a color $ c_{i} $ , connecting vertex $ a_{i} $ and $ b_{i} $ .

Mr. Kitayuta wants you to process the following $ q $ queries.

In the $ i $ -th query, he gives you two integers — $ u_{i} $ and $ v_{i} $ .

Find the number of the colors that satisfy the following condition: the edges of that color connect vertex $ u_{i} $ and vertex $ v_{i} $ directly or indirectly.

输入格式

The first line of the input contains space-separated two integers — $ n $ and $ m $ ( $ 2<=n<=100,1<=m<=100 $ ), denoting the number of the vertices and the number of the edges, respectively.

The next $ m $ lines contain space-separated three integers — $ a_{i} $ , $ b_{i} $ ( $ 1<=a_{i}<b_{i}<=n $ ) and $ c_{i} $ ( $ 1<=c_{i}<=m $ ). Note that there can be multiple edges between two vertices. However, there are no multiple edges of the same color between two vertices, that is, if $ i≠j $ , $ (a_{i},b_{i},c_{i})≠(a_{j},b_{j},c_{j}) $ .

The next line contains a integer — $ q $ ( $ 1<=q<=100 $ ), denoting the number of the queries.

Then follows $ q $ lines, containing space-separated two integers — $ u_{i} $ and $ v_{i} $ ( $ 1<=u_{i},v_{i}<=n $ ). It is guaranteed that $ u_{i}≠v_{i} $ .

输出格式

For each query, print the answer in a separate line.

样例 #1

样例输入 #1

4 5
1 2 1
1 2 2
2 3 1
2 3 3
2 4 3
3
1 2
3 4
1 4

样例输出 #1

2
1
0

样例 #2

样例输入 #2

5 7
1 5 1
2 5 1
3 5 1
4 5 1
1 2 2
2 3 2
3 4 2
5
1 5
5 1
2 5
1 5
1 4

样例输出 #2

1
1
1
1
2

提示

Let’s consider the first sample.

The figure above shows the first sample. - Vertex $ 1 $ and vertex $ 2 $ are connected by color $ 1 $ and $ 2 $ .

  • Vertex $ 3 $ and vertex $ 4 $ are connected by color $ 3 $ .
  • Vertex $ 1 $ and vertex $ 4 $ are not connected by any single color.

思路

(1)并查集
一个二维并查集,一个记录颜色,一个记录点。
(2)Floyed
普通Floyed加一维颜色。数据只有100四维循环不会T。

AC code

(1)并查集

#include<bits/stdc++.h>using namespace std;int fa[1000][1000];
int n, m, t;int find(int x, int i) 
{if (fa[x][i] == x) return x;return fa[x][i] = find(fa[x][i], i); 
}int main()
{cin >> n >> m;for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)fa[i][j] = i; for (int i = 1; i <= m; ++i){int u, v, z;cin >> u >> v >> z;fa[find(u, z)][z] = find(v,z); }cin >> t;while (t--){int u, v, ans = 0;cin >> u >> v;for(int i = 1; i <= m;i++)if (find(u,i) == find(v,i)) ans++; cout << ans << endl;}return 0;
}

(2)Floyed

#include<bits/stdc++.h>using namespace std;int a[101][101][101];int main()
{int n, m;cin >> n >> m;for(int i = 1; i <= m; i++){int u, v, q;cin >> u >> v >> q;a[u][v][q] = 1;a[v][u][q] = 1;}for (int k = 1; k <= n; k++)for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)for (int c = 1; c <= m; c++)if (a[i][k][c] == 1 && a[k][j][c] == 1)a[i][j][c] = 1;int q;cin >> q;for (int i = 1; i <= q; i++){int u, v;cin >> u >> v;int sum = 0;for(int j = 1; j <= m; j++)if(a[u][v][j] == 1)sum++;cout << sum << endl;}return 0;
}
http://www.hkea.cn/news/183921/

相关文章:

  • 哪个网站专业做安防如何注册域名网站
  • 穆棱市住房和城乡建设局网站关键词词库
  • 成都网站建设市场什么是网络营销的核心
  • 深圳找人做网站廊坊优化外包
  • 衡阳市城市建设投资有限公司网站湖南企业seo优化报价
  • css做网站常用百度权重优化软件
  • 合合肥网站建设制作网站用什么软件
  • 杭州网站设计公司推荐网络推广与优化
  • 移动惠生活app下载网址荆门网站seo
  • 做网站很赚钱吗关键词自助优化
  • wordpress小工具里的用户中心南京谷歌优化
  • 网站开发中茶叶网络营销策划方案
  • 临海市住房与城乡建设规划局 网站目前最新的营销模式有哪些
  • 高校建设网站的特色如何建立一个网站
  • 公司做网站域名归谁搜索引擎营销策划方案
  • 怎么做外贸个人网站seo综合查询工具可以查看哪些数据
  • 黑客网站盗qq百度seo公司整站优化
  • 网页设计代码不能运行seo的中文名是什么
  • 灵溪网站建设外贸网站谷歌seo
  • 网站开发系统设计产品推销
  • 不用代码做网站 知乎百度引流推广怎么收费
  • 怎么看网站后台什么语言做的产品全网营销推广
  • 可以做宣传图的网站网络销售管理条例
  • 做书籍封皮的网站制作网站平台
  • 1网站建设公司长沙网站到首页排名
  • 域名还在备案可以做网站吗seo培训班
  • 前程无忧网宁波网站建设类岗位北京网站快速排名优化
  • 如何优化网站内部链接站长工具站长之家
  • 阿里云网站建设的实训报告免费的自媒体一键发布平台
  • 关于加强网站建设的意见企业获客方式