17年秋季第三题 PAT甲级 1142 Maximal Clique (25分)

PAT甲级刷题 测试点坑点总结 PAT甲级刷题 测试点坑点总结 (持续更新中~~) 天呐!刷PAT第一次遇见不给出测试用例的情况,一个个百度真的麻烦,给寄几总结一下ლ(′◉❥◉`ლ)呀,也算是给自己的督促,记得早点刷完呀 (咳咳,1001-1008写的比较早,忘记总结了,哪天刷完题了再补上吧) 1009 Product of Polynomials (25分) 1010 Radix (25分) ... 阅读详情

汇总贴

2020年3月PAT甲级满分必备刷题技巧

题目

来源:https://pintia.cn/problem-sets/994805342720868352/problems/994805343979159552

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from https://en.wikipedia.org/wiki/Clique_(graph_theory))

Now it is your job to judge if a given subset of vertices can form a maximal clique.

Input Specification:

Each input file contains one test case. For each case, the first line gives two positive integers Nv (≤ 200), the number of vertices in the graph, and Ne, the number of undirected edges. Then Ne lines follow, each gives a pair of vertices of an edge. The vertices are numbered from 1 to Nv.

After the graph, there is another positive integer M (≤ 100). Then M lines of query follow, each first gives a positive number K (≤ Nv), then followed by a sequence of K distinct vertices. All the numbers in a line are separated by a space.

Output Specification:

For each of the M queries, print in a line Yes if the given subset of vertices can form a maximal clique; or if it is a clique but not a maximal clique, print Not Maximal; or if it is not a clique at all, print Not a Clique.

Sample Input:

8 10
5 6
7 8
6 4
3 6
4 5
2 3
8 2
2 7
5 3
3 4
6
4 5 4 3 6
3 2 8 7
2 2 3
1 1
3 4 3 6
3 3 2 1

Sample Output:

Yes
Yes
Yes
Yes
Not Maximal
Not a Clique

概念解释

1.clique 团
无向图中,两两之间有边的顶点集合。

2.maximal clique 极大团
是一个团,该团不能被更大的团所包含,换句话说,再也不存在一个点与该团中的任意顶点之间存在一条边。

题目分析

给出无向图,判断是极大团、团或不是团。用反证法的思路去想最快,否定是团或者极大团是很简单的,如果都否定不了就是极大团。

满分代码

#include<iostream>
using namespace std;
const int maxn=205;
int G[maxn][maxn];
int a[maxn],b[maxn];
int main(){
    int n,m,k,l,u,v;
    cin>>n>>m;
    fill(G[0],G[0]+maxn*maxn,0);
    for(int i=0;i<m;i++){
        cin>>u>>v;
        G[u][v]=G[v][u]=1;
    }
    cin>>k;
    for(int i=0;i<k;i++){
        cin>>l;
        fill(a,a+maxn,0);
        fill(b,b+maxn,0);
        for(int j=0;j<l;j++){
            cin>>u;
            a[u]=1;//为了判断是不是有点是孤立的
            b[j]=u;//要判断的团顶点序号
        }
        int maxc=0,cliq=1;
        //判断是不是团
        for(int j=0;j<l-1;j++){
            for(int p=j+1;p<l;p++){
                if(G[b[j]][b[p]]==0){
                    cliq=0;
                }
            }
        }
        if(cliq==0){
            cout<<"Not a Clique"<<endl;
            continue;
        }
        //判断是不是极大团
        for(int p=1;p<=n;p++){
            for(int j=0;j<l;j++){
                if(a[p]==0 && G[b[j]][p]==1){
                    maxc++;
                }
            }
            if(maxc==l){
                break;
            }else{
                maxc=0;
            }
        }
        if(maxc==l){
            cout<<"Not Maximal"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
        
    }
    return 0;
}


 

2020年9月PAT甲级满分必备刷题技巧 这份技巧帮你一网打尽所有的要点 阅读详情

相关推荐

2020年7月第4题 PAT甲级真题 Replacement Selection (30分)

When the input is much too large to fit into memory, we have to do external sorting instead of internal sorting. One of the key steps in external sorting is to generate sets of sorted records (also called runs) with limited internal memory. The simplest me

qiiingc的解题记录 5660

[Python](PAT)1142 Maximal Clique(25 分)

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...

贰拾壹 411

2019年9月8日秋季PAT甲级题解-4 Dijkstra Sequence (30 分) 详细分析

Dijkstra's algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from one particular source vertex to all...

qiiingc的解题记录 3884

A1142【25】 第2/第3个测试点过不去

 柳神的能过。。我的只有20分。。 #include&lt;iostream&gt; #include&lt;vector&gt; using namespace std; int e[205][205] = { 0 }; int main() { int nv, ne, m; cin &gt;&gt; nv &gt;&gt; ne; for (int i = 0; i &lt; n...

zrtzrt1111的博客 452

PAT-2019年冬季考试-甲级-7-1 Good in C (20分)超详解,几招就满分通过

题目: When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows? Input Specification: Each input file contains one test case. For each case, the first part...

qiiingc的解题记录 3640

PAT甲级数据结构类技术总结

本篇文章专门汇总特别需要注意的数据结构,将说明每种数据结构的引入和具体用法。

qiiingc的解题记录 3092

PATA1142 Maximal Clique(测试点2、3)

原题链接PAT甲级1142 Maximal Clique 思路 使用邻接矩阵存储图,G[ u ] [ v ] 为1,代表u和v相通。 可以先判断是否是团,即给的序列中是否有点不连通。 接着判断是否是极大团,即是否还存在着不在序列中的点,这个点可以到所有这个序列中的点。如果存在这样的点的话,即为不是极大团。否则是极大团。 #include <bits/stdc++.h> using namespace std; int n,e,q; bool app[210]; int temp[210].

weixin_44321570的博客 368

【go-libp2p学习笔记】使用go-libp2p搭建中转服务器(circuit relay server)

libp2p算是一个蛮新的库,提供了非常强大的p2p节点发现/连接/通信能力。IPFS的基石。 中文网上的**技术教程**比较少,所以抛砖引玉开一点坑来体验一下!

Cake_C的博客 6491

PAT甲级-1142-Maximal Clique(最大连通分量)

思路: 1.先判断是否是连通分量 如果顶点中有一对不可达,那它就是不是连通分量。 注意:break跳出里层循环后,在外层循环还要再设一个判断让它再跳一次! 2.再判断是否是最大连通分量 如果剩余顶点中有一个顶点的加入使得该图连通了(x是剩余顶点中的一个【一个即可】,y是当前连通分量中的顶点,所有graph[x][y]都为1),那它就不是最大连通分量。 注意:break跳出里层循环后,就可以不用管了...

波点兔的博客 875

保姆级教程:在Davinci Configurator里配置BswM的ECU状态机(附状态切换流程图)

本文提供了一份详细的AUTOSAR BswM模块配置指南,通过Davinci Configurator工具实现ECU状态机的构建与管理。内容涵盖从模式请求端口创建到状态切换规则定义的全流程,特别针对Ecu State Handling进行了深入解析,并附有状态切换流程图,帮助汽车电子工程师高效完成ECU状态管理配置。

weixin_28366475的博客 410

解决[WARN] : Controller Spawner couldn‘t find the expected controller_manager ROS interface.思路

rrbot例程ros_control配置问题的解决思路 本人刚入门ROS机器人开发,在学习rrbot例程出现了control_manager无法启动的bug。 在启动rrbot_control.launch的时候,出现下列warning: [WARN] [1594362016.372059]: Controller Spawner couldn't find the expected controller_manager ROS interface. 之后再按教程的步骤 rosservice call /

qq_40299650的博客 1万+

pat1142 测试点23没通过 待填坑

#include <iostream> #include<vector> #include<algorithm> using namespace std; int graph[201][201]; bool findint(vector<int> &v,int &order,int &a) { while(v[order]<a){order++;} if(order==a) return true; els

weixin_43431998的博客 228

CMN-700组件全解析:从XP路由器到HN-F主节点的实战配置指南

本文深入解析Arm CMN-700片上网络IP的核心组件与实战配置。重点剖析了XP网格路由器的拓扑规划与CHI通道管理,以及HN-F全一致性主节点在维护缓存一致性、管理SLC和地址映射中的关键作用。通过一个12×12网格的配置案例,为硬件工程师提供了从组件布局、地址映射到性能调优的系统级设计指南。

weixin_29313423的博客 282

PAT 甲级 1142 Maximal Clique (25 分)

思路: 1.用map的映射关系存储邻接矩阵; 2.先遍历所有给的点,比较是否邻接,以此判断是不是团; 3.若是团,则遍历所有团中结点,若结点的相邻节点数不等于k-1,则删去团中k-1个结点,将剩下的结点与团中结点比较,比较是否都相邻; 代码: #include<iostream> #include<vector> #include<unordered_set> ...

Yuhan的博客 213

白话详细解读(七)----- CBAM:Convolutional Block Attention Module

一、CBAM简介 论文链接:https://x.sci-hub.org.cn/scholar?hl=zh-TW&as_sdt=0%2C5&q=CBAM%3A+Convolutional+Block+Attention+Module&btnG=&oq=CB CBAM这篇论文是在2018年提出的,自提出之后,已经被引用上千次,可见其影响力。CBAM是一种专门为了卷积神经网络而设计的注意力模块,传统的卷积存在只关注局部信息,而往往忽略全局信息的弊端,以3*3卷积为例,滤波器有9个

奋斗の博客 1万+

声品质粗糙度matlab,声品质的应用分析方法

声品质的应用分析方法2016-04-05 09:18:57阅读次数:14198摘要:声品质分析在噪声的主观评价方面已经得到越来越多的应用。本文比较了声品质分析与传统计权声级的区别,并介绍了在声品质分析的实际应用中,针对稳态信号、非稳态信号的几种不同分析方法,以及各分析方法的要求和特点。关键词:声品质,响度,尖锐度,粗糙度,波动度1前言传统评价噪声的方法主要为计权声压级,用以反映声音的大小。但是人耳...

weixin_30767323的博客 2438

PAT_甲级_1142 Maximal Clique (25point(s)) (C++)【图的应用/clique】

目录 1,题目描述 题目大意 2,思路 3,AC代码 4,解题过程 第一搏 第二搏 第三搏 1,题目描述 clique:派系; 私党; 小集团; 小圈子; Sample Input: 8 10 5 6 7 8 6 4 3 6 4 5 2 3 8 2 2 7 5 3 3 4 6 4 5 4 3 6 3 2 8 7 2 2 3 1 1 3 4 3 6 3 3 2 1 ...

&再见萤火虫&的博客 390

用FPGA在HDMI上显示自定义字符:从COE文件到OSD叠加的保姆级教程

本文详细介绍了如何在FPGA上实现HDMI视频流的OSD字符叠加技术,从COE文件生成到动态区域控制的完整流程。通过Verilog代码示例和实战技巧,帮助开发者掌握字符ROM设计、像素坐标追踪和动态混合等核心技术,适用于视频监控、系统状态显示等应用场景。

weixin_28720767的博客 231

PAT 1142. Maximal Clique (25) - 甲级

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...

柳婼 の blog 4350

UltraScale系列底层结构(3)——URAM概述

在UltraScale+™ 器件中,除了我们在常规熟悉的BRAM资源以外,还额外提供了URAM(UltraRAM)资源。 UltraRAM 是一种单时钟同步操作的高密度存储器,每个 UltraRAM 块可存储 288 Kb 数据,配置为 4K x 72 位的存储单元,其容量是 Block RAM 的八倍。虽然 UltraRAM 内部使用单端口存储单元,但通过在一个时钟周期内顺序执行端口 A 和端口 B 的操作,实现了双端口功能。

apple_53311083的博客 2832

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

1142 Maximal Clique (25 分)(读懂题目,清楚分析)

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from https://en.wikipedia.org/wiki

weixin_45962741的博客 187

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

PAT甲级2017秋季1136 A Delayed Palindrome (20分)

1136 A Delayed Palindrome (20分) Non-palindromic numbers can be paired with palindromic ones via a series of operations. First, the non-palindromic number is reversed and the result is added to the original number. If the result is not a palindromic number

0 1055

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

1142 Maximal Clique (25 分)

题意 给定几个点,判断是否为极大团,即每两个顶点都有边连接。 判断给定的点是否两两都有边,将题目中的所给的测试顶点的所有邻接的点都加1,最后在这几个点循环看一下每个点入度是否等于k-1(顶点数减1),如果是则为团。 然后如果存在一个点,使得其不为极大团,则必有一个或多个不在给出的数据里面的点,其入度为k code #include <bits/stdc++.h> using nam...

m714星云的博客 285

PAT甲级1142 Maximal Clique (25 分)

1142Maximal Clique(25分) Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extend...

Dexter 223

PAT A1142 Maximal Clique (25 分)——图

Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extended by including one...

weixin_30692143的博客 169

18冬第二题 PAT甲级 1153 Decode Registration Card of PAT (25分) 鸡贼的题

题目 A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test sit...

qiiingc的解题记录 3万+
上一篇: 18年冬季第四题 PAT甲级 1155 Heap Paths (30分)
下一篇: 19年春季第四题 PAT甲级 1159 Structure of a Binary Tree(30分)
浒鱼鱼
博客等级 码龄11年 287粉丝 70原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值