题意

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. ETCD:客户端v3

    原文地址:etcd/clientv3 etcd/clientv3是v3版本的Go etcd官方客户端 安装 go get go.etcd.io/etcd/clientv3 开始 创建客户端使用clie ...

  2. Java面向对象之继承(一)

    目录 Java面向对象之继承 引言 继承的特点 语法格式 父子类的关系 继承要点 重写父类方法 继承中的构造器 继承中的super关键字 ... Java面向对象之继承 继承是面向对象的第二大特征,是 ...

  3. Hello universe!

    Hello, universe. This is my first cnblogs article.this blog apply to computer technology and another ...

  4. Windows7安装PowerShell5.1方法(Flutter新版本需要)

    Windows7安装PowerShell5.1方法(Flutter新版本需要)   重新安装Windows7系统,在使用Flutter的时候,发现需要PowerShell5.0以上版本,需要升级Win ...

  5. Unable to connect to the server: x509: certificate signed by unknown authority

    0x00 Problem 在使用二进制搭建 k8s 集群的过程中,使用 kubectl get 等操作时始终显示 x509: certificate signed by unknown authori ...

  6. mysql操作进阶

    # ### part1 单表查询# sql 查询语句的完整语法 ''' select .. from .. where .. group by .. having .. order by .. lim ...

  7. js知识点面试题

    网上看到的一个题,在这里存一下 此为题目function Foo() { getName = function () { alert (1); }; return this; } Foo.getNam ...

  8. Appium(二):Node.js下载与安装、非GUI版本appium下载与安装、GUI版本appium下载与安装

    1. 下载并安装Node.JS 进入官网:https://nodejs.org/en/. 由于我们是新手嘛,所以肯定是越稳定越好啦,所以选择下载LTS版本. 进入文件下点击文件就进入安装界面了,点击n ...

  9. [主动学习--查询策略] 01 Core-set

    符号定义 主动学习每一次迭代选择的样本数量为一个 budget 训练集中初始无标签数据集记为 unlabeled data,\(\bm{u}^0\) 训练集中初始有标签数据集记为 initial la ...

  10. 第K个语法符号

    在第一行我们写上一个 0.接下来的每一行,将前一行中的0替换为01,1替换为10. 给定行数 N 和序数 K,返回第 N 行中第 K个字符.(K从1开始) 例子: 输入: N = 1, K = 1输出 ...