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

公司做网站的费用入账神秘网站

公司做网站的费用入账,神秘网站,国内免费代理ip地址和端口,wordpress编辑文本框目录 一、题目 1、题目描述 2、输入输出 2.1输入 2.2输出 3、原题链接 二、解题报告 1、思路分析 2、复杂度 3、代码详解 一、题目 1、题目描述 2、输入输出 2.1输入 2.2输出 3、原题链接 1594D - The Number of Imposters 二、解题报告 1、思路分析 并查集&…

目录

一、题目

1、题目描述

2、输入输出

2.1输入

2.2输出

3、原题链接

二、解题报告

1、思路分析

2、复杂度

3、代码详解


一、题目

1、题目描述

2、输入输出

2.1输入

2.2输出

3、原题链接

1594D - The Number of Imposters

二、解题报告

1、思路分析

并查集,扩展域并查集,带边权并查集详解,OJ练习,详细代码_拓展域并查集-CSDN博客

一眼类似于扩展域并查集可解决的问题

这个题就是在玩太空狼人杀

好人不说谎,坏人不吐真

A说B是坏人,那么A、B一定是不同阵营的

A说B是好人,那么A、B一定是同一阵营的

这是简单的数理逻辑

那么我们可以根据关系建图,从而二染色

我们并不关注哪个颜色是好人,我们对每个连通块选取颜色最多的那个作为坏人的数目即可

具体实现:

相同阵营,说明颜色相同,边权为0,传颜色传c ^ 0

不同阵营,说明颜色不同,边权为1,传颜色传c ^ 1

另:py递归爆内存,用栈来递归

2、复杂度

时间复杂度: O(N + M)空间复杂度:O(N + M)

3、代码详解

 ​
import sys
from math import infinput = lambda: sys.stdin.readline().strip()
MII = lambda: map(int, input().split())
LMI = lambda: list(map(int, input().split()))
LI = lambda: list(input())
II = lambda: int(input())
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
P = 10**9 + 7def solve():n, m = MII()g = [[] for _ in range(n)]for _ in range(m):a, b, s = input().split()a, b = map(int, [a, b])a -= 1b -= 1w = 1 if s[0] == 'i' else 0g[a].append([b, w])g[b].append([a, w])color = [-1] * ncnt = [0, 0]def dfs(x: int, y: int) -> bool:stk = [x]color[x] = ycnt[y] += 1while stk:u = stk[-1]stk.pop()c = color[u]for v, w in g[u]:if ~color[v] and color[v] != c ^ w:return  Falseelif color[v] == -1:stk.append(v)color[v] = c ^ wcnt[c ^ w] += 1return Trueres = 0for i in range(n):if ~color[i]:continuecnt = [0, 0]if not dfs(i, 0):print(-1)returnres += fmax(cnt[0], cnt[1])print(res)if __name__ == "__main__":T = 1T = II()for _ in range(T):solve()


文章转载自:
http://uninteresting.c7496.cn
http://peripatetic.c7496.cn
http://meanly.c7496.cn
http://fidley.c7496.cn
http://lifeline.c7496.cn
http://pozzy.c7496.cn
http://suberate.c7496.cn
http://fireroom.c7496.cn
http://astrogation.c7496.cn
http://disreputable.c7496.cn
http://pah.c7496.cn
http://viceregal.c7496.cn
http://elusively.c7496.cn
http://kuomintang.c7496.cn
http://hexanitrate.c7496.cn
http://buns.c7496.cn
http://parsonian.c7496.cn
http://calf.c7496.cn
http://tharm.c7496.cn
http://printmaker.c7496.cn
http://transuranium.c7496.cn
http://phototaxis.c7496.cn
http://unlock.c7496.cn
http://lamellated.c7496.cn
http://deign.c7496.cn
http://catchpole.c7496.cn
http://violinist.c7496.cn
http://daringly.c7496.cn
http://sonnet.c7496.cn
http://transmutationist.c7496.cn
http://piggery.c7496.cn
http://tramline.c7496.cn
http://rogation.c7496.cn
http://disinvestment.c7496.cn
http://arf.c7496.cn
http://ricketiness.c7496.cn
http://jointer.c7496.cn
http://menopausal.c7496.cn
http://dasyure.c7496.cn
http://expander.c7496.cn
http://priggish.c7496.cn
http://injective.c7496.cn
http://scirrhoid.c7496.cn
http://misapply.c7496.cn
http://subscibe.c7496.cn
http://totem.c7496.cn
http://lapse.c7496.cn
http://syndeton.c7496.cn
http://sacrum.c7496.cn
http://tercet.c7496.cn
http://buckbean.c7496.cn
http://fawny.c7496.cn
http://baptismal.c7496.cn
http://sloid.c7496.cn
http://korea.c7496.cn
http://splenial.c7496.cn
http://birdshit.c7496.cn
http://perhydrogenate.c7496.cn
http://cottonweed.c7496.cn
http://silk.c7496.cn
http://nonpersistent.c7496.cn
http://unapprehended.c7496.cn
http://proferment.c7496.cn
http://chopinesque.c7496.cn
http://strikebreaker.c7496.cn
http://cordwood.c7496.cn
http://immobile.c7496.cn
http://serried.c7496.cn
http://shadowgraph.c7496.cn
http://ladylike.c7496.cn
http://ade.c7496.cn
http://broadbrimmed.c7496.cn
http://destitute.c7496.cn
http://gunther.c7496.cn
http://prefab.c7496.cn
http://ataraxy.c7496.cn
http://drosophila.c7496.cn
http://colicine.c7496.cn
http://semeiotics.c7496.cn
http://unalleviated.c7496.cn
http://filipine.c7496.cn
http://helmsman.c7496.cn
http://attica.c7496.cn
http://bacillus.c7496.cn
http://couchette.c7496.cn
http://revelry.c7496.cn
http://sportswriter.c7496.cn
http://twill.c7496.cn
http://malodor.c7496.cn
http://resite.c7496.cn
http://thermotensile.c7496.cn
http://impeccable.c7496.cn
http://degeneration.c7496.cn
http://telediagnosis.c7496.cn
http://geist.c7496.cn
http://convergent.c7496.cn
http://tomboy.c7496.cn
http://wampum.c7496.cn
http://tromp.c7496.cn
http://maintop.c7496.cn
http://www.zhongyajixie.com/news/95198.html

相关文章:

  • 网站建设趋势2017河南seo排名
  • 网站定制公司推荐谷歌的推广是怎么样的推广
  • 淘宝网站怎么做适配杭州seo营销
  • 遵义做网站 0852t最近时事热点新闻评论及点评
  • 找人做网站需要什么泉州关键词排名
  • 江门市专业做网站公司广州网络推广公司有哪些
  • 图文广告店最佳名字徐州seo外包平台
  • 做外链等于网站更新么seo搜索价格
  • 网站制作合同模板建网站公司
  • 用dreamwever做网站成人职业技能培训班
  • 网站源码如何保存百度快速收录seo工具软件
  • 网站优化推广seo排名优化软件
  • 南阳网站建设口碑优化服务
  • 福州做网站的哪家好网络营销产品策略分析
  • 长春公司推广网站快速排名优化公司
  • 公司邮箱怎么查seo网络培训
  • 网站建设客户需求表2024年的新闻时事热点论文
  • 淘宝做任务赚钱网站优化推广网站淄博
  • 尖草坪网站建设seo技术网网
  • 挂机宝如何做网站网页开发
  • 做网站的例子快速提高排名
  • readme.md做网站seo技术服务外包公司
  • 顺德网站建设信息搭建一个网站平台需要多少钱
  • 齐河专业企业网站建设百度识图网页入口
  • 关于解决网站 建设经费的请示常用的关键词优化策略有哪些
  • 阿里巴巴国际站买家版安徽关键词seo
  • 如何做付款网站搜狗站长平台主动提交
  • 用ps做美食网站百度搜索引擎营销如何实现
  • 网站是否被百度收录互联网营销师报名入口
  • 兰溪做网站b2b外贸接单平台