题意

https://vjudge.net/problem/CodeForces-1230C

给了你总共有21张多米诺骨牌,每张牌有两个面,然后给你一个无向图,保证没有环和一个顶点多条边的情况存在。现在让你在这个图中的每个边放多米诺骨牌。有一个放置规则,问你最多能放几张多米诺骨牌上去。 放置规则就是,每个点的权值都是一样的,你在每条边上放的多米诺骨牌,因为它有两个面。需要保证两个面上面的大小就是它指向的点的权值。

4 4
1 2
2 3
3 4
4 1

Here is an illustration of Anadi's graph from the first sample test:

And here is one of the ways to place a domino on each of its edges:

 

思路

建议直接看样例,题意就理解了。

当n<7时,显然所有边都能满足。

当n==7时,枚举两个点取值相同,然后求这两个点共同连的点数(不合法的情况),用m减去这个最小值即可。

代码

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
int g[8][8];
int main()
{
std::ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
g[u][v]=g[v][u]=1;
}
if(n<7)
{
cout<<m<<endl;
return 0;
}
int mn=inf;
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
int t=0;
for(int k=1;k<=n;k++)
{
if(g[i][k]&&g[k][j])
{
t++;
}
}
mn=min(t,mn);
}
}
cout<<m-mn<<endl;
return 0;
}

  

CodeForces - 1230C(思维/暴力)的更多相关文章

  1. codeforces 768 C. Jon Snow and his Favourite Number(思维+暴力)

    题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后 ...

  2. CodeForces - 1244D (思维+暴力)

    题意 https://vjudge.net/problem/CodeForces-1244D 有一棵树,有3种颜色,第i个节点染成第j种颜色的代价是c(i,j),现在要你求出一种染色方案,使得总代价最 ...

  3. CodeForces - 1248D1 (思维+暴力)

    题意 有一个括号序列,你可以选择两个位置i,j(i可以等于j),进行交换.使得最后的循环位置(i的数目)最大. 循环位置:i(0<=i<len),将前i个字符移到最后,得到的新序列是合法的 ...

  4. Nice Garland CodeForces - 1108C (思维+暴力)

    You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ...

  5. CodeForces - 593A -2Char(思维+暴力枚举)

    Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is th ...

  6. CodeForces - 1228D (暴力+思维+乱搞)

    题意 https://vjudge.net/problem/CodeForces-1228D 有一个n个顶点m条边的无向图,在一对顶点中最多有一条边. 设v1,v2是两个不相交的非空子集,当满足以下条 ...

  7. Nikita and string [思维-暴力] ACM

    codeforces Nikita and string time limit per test   2 seconds memory limit per test   256 megabytes O ...

  8. Karen and Game CodeForces - 816C (暴力+构造)

    On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as fo ...

  9. Chladni Figure CodeForces - 1162D (暴力,真香啊~)

    Chladni Figure CodeForces - 1162D Inaka has a disc, the circumference of which is nn units. The circ ...

随机推荐

  1. 同步IO, 异步IO的理解

    1. 什么是IO? 在计算机中无时无刻不存在着对数据的访问和读取(数据都存储在物理的媒介上,例如寄存器,高速缓存,内存,磁盘,网卡等等),这些操作被称为IO. 2. 阻塞IO (1)当用户线程发起IO ...

  2. Java中的日期与时间

    日期与时间 最常用的几个类,Date.DateFormat.Calendar.Locale Date 1.无参构造方法 //根据当前系统默认的毫秒值创建时间对象 public Date() { thi ...

  3. Vue初始化过程

    用vue也有一两年了,始终对vue一知半解,不怎么了解内部的执行过程,最近在看vue源码,还是不少收获的,其中不乏浏览器事件轮询机制.闭包.设计模式等,还是非常值得一读.本篇简要记录下vue的初始化过 ...

  4. 七、3Dslicer的坐标系

    一.参考博客 https://blog.csdn.net/Huadong_eddy/article/details/84988166

  5. 手机投屏工具与HOSTS切换工具

    ApowerMirror windows -->switchhosts

  6. Java内存分析工具MAT

    MAT是一个强大的内存分析工具,可以快捷.有效地帮助我们找到内存泄露,减少内存消耗分析工具.内存中堆的使用情况是应用性能监测的重点,而对于堆的快照,可以dump出来进一步分析,总的来说,一般我们对于堆 ...

  7. error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in

    问题: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_ ...

  8. php中文乱码原因和维修方法

    一.首先是PHP网页的编码 1.如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; charset=gb2312”),静态页面添加,所有文 ...

  9. tf.train.Saver()

    1. 实例化对象 saver = tf.train.Saver(max_to_keep=1) max_to_keep: 表明保存的最大checkpoint文件数.当一个新文件创建的时候,旧文件就会被删 ...

  10. 上海街头灵魂摄影师:勤劳de小懒熊

    上海中年大叔,街头摄影师,眼光比较独特,题材不限于: 酒吧晚上醉酒躺尸的.喝多亲嘴的.拉拉les的.流泪告别的.地铁露肉的.短裤露沟的. 尺度不大,但比较真实,艺术来源于生活,比那些摆拍的有意思. 大 ...