CodeForces - 1230C(思维/暴力)
题意
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(思维/暴力)的更多相关文章
- codeforces 768 C. Jon Snow and his Favourite Number(思维+暴力)
题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后 ...
- CodeForces - 1244D (思维+暴力)
题意 https://vjudge.net/problem/CodeForces-1244D 有一棵树,有3种颜色,第i个节点染成第j种颜色的代价是c(i,j),现在要你求出一种染色方案,使得总代价最 ...
- CodeForces - 1248D1 (思维+暴力)
题意 有一个括号序列,你可以选择两个位置i,j(i可以等于j),进行交换.使得最后的循环位置(i的数目)最大. 循环位置:i(0<=i<len),将前i个字符移到最后,得到的新序列是合法的 ...
- Nice Garland CodeForces - 1108C (思维+暴力)
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ...
- CodeForces - 593A -2Char(思维+暴力枚举)
Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is th ...
- CodeForces - 1228D (暴力+思维+乱搞)
题意 https://vjudge.net/problem/CodeForces-1228D 有一个n个顶点m条边的无向图,在一对顶点中最多有一条边. 设v1,v2是两个不相交的非空子集,当满足以下条 ...
- Nikita and string [思维-暴力] ACM
codeforces Nikita and string time limit per test 2 seconds memory limit per test 256 megabytes O ...
- 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 ...
- Chladni Figure CodeForces - 1162D (暴力,真香啊~)
Chladni Figure CodeForces - 1162D Inaka has a disc, the circumference of which is nn units. The circ ...
随机推荐
- 每天进步一点点----JS之比较运算符易错点
1.字符串的比较 字符串也是可以比较的,字符串比较的asc码顺序:asc有128位,由7位二进制数表示,每个数对应的是一个字符.ASC码有ASC码1,由7位二进制1数表示:ASC2码又8位二进制数表示 ...
- JavaBean动态添加删除属性
1.cglib BeanGenerator beanGenerator = new BeanGenerator(); beanGenerator.addProperty("id", ...
- Java 操作Word书签(三):用文本、图片、表格替换书签
本篇文章将继续介绍通过Java来操作Word书签的方法,即替换Word中已有书签,包括用新的文本.图片.表格等替换原有书签处的内容. 使用工具:Free Spire.Doc for Java (免费版 ...
- SpringBoot2.0整合WebSocket,实现后端数据实时推送!
之前公司的某个系统为了实现推送技术,所用的技术都是Ajax轮询,这种方式浏览器需要不断的向服务器发出请求,显然这样会浪费很多的带宽等资源,所以研究了下WebSocket,本文将详细介绍下. 一.什么是 ...
- Java并发面试问题,谈谈你对AQS的理解
本人免费整理了Java高级资料,涵盖了Java.Redis.MongoDB.MySQL.Zookeeper.Spring Cloud.Dubbo高并发分布式等教程,一共30G,需要自己领取.传送门:h ...
- mysql-5.7.27安装
1,下载5.7.27安装包 百度网盘 (注:5.7.27要安装net faframework4.5.2) 2,创建my.ini及data文件 下载5.7.27后解压,在创建my.ini文件及d ...
- How to: Generate XPO Business Classes for Existing Data Tables 如何:为现有数据表生成 XPO 业务类
From the Tutorial and other documentation sources, you learned how to create business classes for yo ...
- How to: Display a List of Non-Persistent Objects in a Popup Dialog 如何:在弹出对话框中显示非持久化对象列表
This example demonstrates how to populate and display a list of objects that are not bound to the da ...
- uml统一建模语言学习笔记(一)
UML是一种统一建模语言,他是以面向对象的方式来实现对任何的系统进行描述的一种语言, 它包括9种图形+包图,分为静态和动态两种,也就是结构图和行为图 “静态”图有:用例图.类图.对象图.部署图.构件图 ...
- (草稿)如何判断一名UiPath开发人员是否合格?
一名合格的UiPath开发人员究竟需要具备什么核心技能?业务梳理?沟通技巧?VB.net吗?VBA吗?Python?还是SQL?出于多种原因,关于这一点总是众说纷纭,莫衷一是.尽管这些技术都算沾边,但 ...