PAT a1134

基于STC8G1K08A单片机的EC11旋转编码器控制(江科大同款,代码可直接使用) 本文介绍了STC8G系列单片机与EC11旋转编码器的接口实现方案。硬件方面详细说明了EC11编码器的机械结构、电气特性及与单片机的典型连接电路,包括上拉电阻和消抖设计。软件部分重点阐述了状态检测算法,通过状态机和查找表实现方向判断,采用中断方式检测信号变化,并配合定时器进行软件消抖处理。文章还提供了完整的代码实现,包括GPIO初始化、中断服务函数、状态转换逻辑等关键模块,展示了如何通过串口输出验证旋转计数。最后讨论了抗抖动优化、高低速应用场景等实际问题解决方案。该方案在菜单导航、参数调节等场景中具有实用价值 阅读详情

目的:判断是不是vertex cover。

输入:

N   <=10000  总点数 0~N-1

M   <=10000  总边数

M条边

K  <=100  查询数

K个查询:

格式:

Nv  v[1] v[2]...v[Nv]

Nv  集合的顶点数  v[i] 顶点的参数

输出:

如果是Vertex cover  输出  Yes

如果不是   输出No。

算法:

判断是不是vertex cover ,一个集合,图的每一条边至少包括集合的一个点。则称为vertex。暴力枚举。用链表存边。每次查询,看是否存在点,若不存在,输出No.遍历完全后输出Yes。

#include<stdio.h>
#include<vector>
#include<map>

using namespace std;

const int maxn = 10010;
vector<int>  g[maxn];
int N,M,K;
map<int,bool> h;
int Nv;

bool isvertexcover()
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<g[i].size();j++)
        {
            int u = i;
            int v = g[i][j];
            if(h[u]==false&&h[v]==false)
            {
                return false;
            }
        }
    }
    return true;
}
int main()
{
    scanf("%d%d",&N,&M);

    for(int i=0;i<M;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
    }

    scanf("%d",&K);
    for(int i=0;i<K;i++)
    {
        scanf("%d",&Nv);
        h.clear();
        for(int j=0;j<Nv;j++)
        {
            int v;
            scanf("%d",&v);
            h[v] = true;
        }
        if(isvertexcover())
        {
            printf("Yes\n");
        }else
        {
            printf("No\n");
        }
    }
    return 0;
}

反思:可以从点出发,看是否每条边都包括了。也可以从边出发,看边的两端点是否存在在集合中。

道威棱镜的设计参考 阅读详情

相关推荐

SwissADME:一款在线预测小分子药动学性质的工具

是一个免费的在线工具,由瑞士生物信息学研究所(SIB)开发,用于预测和分析小分子的药物相似性、理化性质、药代动力学特性以及合成可行性等。它是药物设计和开发中常用的工具之一,帮助研究人员快速评估化合物的成药潜力。

药研猿的博客 5018

PAT乙级 1023 组个最小数

#include<iostream> #include<string> #include<map> #include<algorithm> #include<bits/stdc++.h> using namespace std; int main(void){ int n; vector<int> vec; for(int i=0; i<10; i++) { cin>&g.

邹九的个人博客 570

STM32F103 实例应用(10)——I2C读写24C32

一、应用简介 本文介绍24C32的读写,基于野火的软件I2C程序。 board_i2c.h /**=========================================================================== @file board_i2c.h @brief 本文件是用于I2C驱动 @author 青梅煮久 @version r0.1 @date 2021/01/13 -------------------------.

qq_34118600的博客 3447

PAT 甲级 1134 顶点覆盖

PAT 甲级 1134 顶点覆盖

赵小轩的博客 571

深入Android构建系统:一次修改ro.vendor.build.fingerprint失败的排查与解决记录

本文深入探讨了Android构建系统中修改ro.vendor.build.fingerprint的完整解决方案。通过分析vendor分区的特殊地位和构建指纹的生成路径,提供了三种实战修改方法,并揭示了指纹修改可能遇到的陷阱与对策,帮助开发者彻底解决这一常见问题。

weixin_30621711的博客 141

Claude Code 使用 OpenAI Codex(GPT-5.3-Codex)完整配置教程

通过 LiteLLM 可以让 Claude Code 调用任何模型,包括:OpenAIDeepSeekGemini本地模型↓↓优点:不依赖 Anthropic API可自由切换模型支持统一 AI Gateway这种“LLM Gateway 架构”正在成为 AI 开发工具的主流实践。

Jacobe_zhao的博客 1万+

PAT【甲级】1134

题目链接:PAT【甲级】1134 题目简述:给定一个图的顶点数N,顶点编号为0 - N-1,又给了边数M,输入整个图。问:给定一组数据,由顶点构成,这些顶点能否引申出所有的边。 #include<bits/stdc++.h> using namespace std; unordered_map<int, bool> vis; vector<pair<int, int>> graph; int main(){ int N, M, K, u, t;

qq_41375322的博客 226

告别抓瞎!手把手教你用Keysight Infinium和M8040完成PCIe 5.0 TX/RX信号完整性测试

本文详细介绍了如何使用Keysight Infinium示波器和M8040误码仪完成PCIe 5.0 TX/RX信号完整性测试。从测试前的设备准备、软件配置到具体的TX信号测试步骤和RX容限测试实战,提供了全面的操作指南和常见问题解决方案,帮助工程师高效完成PCIe 5.0合规性测试。

weixin_30911451的博客 503

第十六天PAT-A1134 Vertex Cover简单模拟边的遍历

A1134 Description: 给一个图,和一组已覆盖的节点,求该覆盖是否涵盖了所有边的至少一个点; 思路: 模拟 #include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #i

giggle66的博客 188

OctoMag: An Electromagnetic System for 5-DOF Wireless Micromanipulation

电磁线圈组驱动经典系统,可以作为参考。 OctoMag: 用于5自由度无线微操作的一个电磁铁系统 OctoMag: An Electromagnetic System for 5-DOF Wireless Micromanipulation [1] Paper Link Authors: J. J. Abbott, etc. 2010, TRO IEEE Transactions on Robot...

XU Yangxin的博客 1665

LLaMA-Factory微调教程2:命令行sft微调

本文介绍了如何使用llama-factory项目在本地运行Qwen2-7B大语言模型进行对话。首先通过llamafactory-cli env查看环境配置,然后使用git lfs下载Qwen2-7B模型。创建配置文件qwen2_7b_instruct.yaml,修改模型路径和模板参数。最后通过llamafactory-cli chat命令启动对话服务,加载模型配置文件和tokenizer,完成环境初始化后即可进行交互式对话。

Cachel Wood的博客 8814

PAT A1134 2018.08.18 【图】

1134Vertex Cover(25分) Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you...

一个非计算机专业的 博客 254

agent实战专栏|日程管理Agent:智能时间管家

在快节奏的现代生活中,时间管理已成为每个人面临的核心挑战。根据全球知名调研机构 Gallup 的统计数据,现代职场人平均每天仅能有效专注工作 2 小时 23 分钟,剩余时间被会议、邮件、碎片化事务大量占据。微软的另一项研究显示,知识工作者平均每天需要处理 200 多条日程相关的信息,包括会议邀请、日历变更、提醒通知等。传统的日历工具(如 Google Calendar、Outlook Calendar、Apple Calendar)虽然在可视化展示和基础提醒方面表现出色,但在智能化方面仍存在明显短板:日程管

2201_76125393的博客 52

PAT-A 1134 题解

PAT-A 1134 题解 思路分析: 这道题其实还是比较简单的,毕竟没有让我们求最小VC(如果要求这个就。。。巨麻烦好吧,模板都要背死你)。 题目的意思是给定一个集合,让我们看看这个集合中的点是不是出现在所有的边里面。 如果我们以边作为研究对象来建立图,那么做法也比较暴力。每一次查找,遍历所有的边,然后看看这个边里面的结点是不是出现在给定的集合中。由于给定的集合数量大小不确定,可能和n一样大。那么,这样算法的时间复杂度为O(nm)。题目中虽然给定了n,m<10^4,但是处理10 ^8的数据一定会超时

weixin_44702215的博客 206

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

PAT_A1134#Vertex Cover

Source: PAT A1134Vertex Cover(25分) Description: Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a g...

weixin_34129696的博客 171

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

【PAT】A1134 Vertex Cover【最小顶点覆盖】

A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...

elegant coder 931

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

PAT(A) 1134. Vertex Cover (25)

原题目: 原题链接:https://www.patest.cn/contests/pat-a-practise/1134 1134. Vertex Cover (25) A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at l...

萧易桥的博客 511

PAT A1134

Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover or not. Input Specificati..

rookie2117的博客 110

PAT A1134 Vertex Cover

PAT A1134 Vertex Cover Sample Input: 10 11 8 7 6 8 4 5 8 4 8 1 1 2 1 4 9 8 9 1 1 0 2 4 5 4 0 3 8 4 6 6 1 7 5 4 9 3 1 8 4 2 2 8 7 9 8 7 6 5 4 2 Sample Output: No Yes Yes No No word meaning i...

qq_42347617的博客 189

pat 甲级 图 A1134 Vertex Cover (25分)

1134 Vertex Cover (25分) A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover o

weixin_42358356的博客 145

1134. Vertex Cover (25)

题目详情:https://www.patest.cn/contests/pat-a-practise/1134 Vertex Cover(边覆盖):在图G=(V,E)中,是否存在顶点的子集,包含G中的每一条边e;如果存在这样的顶点的子集那么就为Vertex Cover,否则就不是。#include <iostream> #include <vector> #include <map> #inclu

LiuY_ang的博客 656

PAT甲级A1134 Vertex Cover (25 分)

A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...

vir_lee的博客 281

PAT | A1134 Vertex Cover

#include <iostream> #include <unordered_set> #include <vector> using namespace std; struct Road{ int u,v; }; Road roads[10010]; unordered_set<int> vertice; int main(){ in...

yehonglin29的博客 142

PAT A 1134 AC代码

给边记一下号,v[x]用来记录点x连着的边 对每一个序列有一个tag数组初始为0,将出现的点连着的边标记为1,再遍历一遍tag,全为1则Yes #include<iostream> #include<vector> using namespace std; int N,M,K; vector<int> v[10000]; int main(){ cin>>N>>M; for(int i=0;i<M;i++){ int v1,v

maxleo928的博客 127

PAT甲级——A1134 Vertex Cover【25】

Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell...

weixin_30632089的博客 122

1134. Vertex Cover (25)[图的遍历]

1. 原题: https://www.patest.cn/contests/pat-a-practise/1134 2. 思路 题意: 给出一个图,点的集合,判断图中所有边的至少一个点是否都包含在集合中。 思路: 图的遍历问题。 遍历每条边,看边的两点是否至少一点在集合里,否则输出no。 用了容器set。 3. 源码(已AC) #include #include #inc

坚不萌 491
上一篇: PAT a1135
下一篇: PAT a1133
CSlerner
博客等级 码龄9年 153粉丝 55原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值