思路:

很有意思的思维题。

实现:

 #include <bits/stdc++.h>
using namespace std;
int check(vector<int>& v, set<pair<int, int>>& st)
{
int res = ;
map<pair<int, int>, int> mp;
for (int i = ; i <= ; i++)
{
for (int j = i; j <= ; j++)
{
mp[make_pair(i, j)] = ;
}
}
for (auto it: st)
{
int a = v[it.first - ], b = v[it.second - ];
pair<int, int> tmp(min(a, b), max(a, b));
if (mp[tmp] == )
{
mp[tmp] = ; res++;
}
}
return res;
}
int main()
{
int n, m, a, b;
while (cin >> n >> m)
{
set<pair<int, int>> st;
for (int i = ; i < m; i++)
{
cin >> a >> b;
st.insert(make_pair(min(a, b), max(a, b)));
}
if (n <= ) { cout << m << endl; continue; }
vector<int> a{, , , , , , };
int maxn = ;
do
{
maxn = max(maxn, check(a, st));
} while (next_permutation(a.begin(), a.end()));
cout << maxn << endl;
}
return ;
}

CF1210A Anadi and Domino的更多相关文章

  1. C. Anadi and Domino

    题目链接:http://codeforces.com/contest/1230/problem/C C. Anadi and Domino time limit per test: 2 seconds ...

  2. 588 div2 C. Anadi and Domino

    C. Anadi and Domino 题目链接:https://codeforces.com/contest/1230/problem/C Anadi has a set of dominoes. ...

  3. Anadi and Domino

    C - Anadi and Domino 参考:Anadi and Domino 思路:分为两种情况: ①n<=6,这个时候肯定可以保证降所有的边都放上一张多米诺牌,那么答案就是m ②n==7, ...

  4. Codeforces Round #588 (Div. 2) C. Anadi and Domino(思维)

    链接: https://codeforces.com/contest/1230/problem/C 题意: Anadi has a set of dominoes. Every domino has ...

  5. cf-1230C Anadi and Domino

    题目链接:http://codeforces.com/contest/1230/problem/C 题意: 有21 个多米诺骨牌,给定一个无向图(无自环,无重边),一条边上可以放一个多米诺骨牌.如果两 ...

  6. Codeforces Round #588 (Div. 2)

    传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...

  7. codeforces刷题记录

    Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) C. Magic Grid 这种题直接构造 数n是2的n次方的倍数的时候可以这样划分数 ...

  8. BPM Domino集成解决方案

    一.需求分析 Lotus Notes/Domino是IBM的协同办公平台,在国内有广泛的用户. 但由于推出年头较早.采用文档数据库等特点, 导致其流程集成能力弱.统计分析难.不支持移动办公等问题,很多 ...

  9. 【转载】给那些想多学习,多进步的Domino初学者

    在这个社区里面,包括QQ技术群里面混了很久了.遇到了很多Domino初学者,也认识了很多致力于Domino这个技术领域的朋友,很开心.很久没有写长篇大论给大家了.我要把一些想法写出来,共大家参考.讨论 ...

随机推荐

  1. @select注解中可以用条件构造器

    https://mp.baomidou.com/guide/wrapper.html#lambda https://blog.csdn.net/weixin_42236404/article/deta ...

  2. 四川大学第二届SCUACM新生赛(同步赛)题解

    周末没事干,就不要脸地去一边吃饭一边看学弟沈阳拿银一边水了个比赛,水都水了,简单写个题解. 比赛链接 A,丁姐姐喜欢Fibonacci.签到1,斐波那契%3 1 1 0 1 1 0 1 1 0..., ...

  3. Gitlab 服务器搭建

    一.官网地址 首页:https://about.gitlab.com/ 安装说明:https://about.gitlab.com/installation/ 二.安装命令摘录 实际问题:yum 安装 ...

  4. 算法练习 —— LeetCode 1-20题

    一.两数之和 1.1 题目描述 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数. 你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用. 示例: 给定 nums = [2, 7, ...

  5. 多线程-Thread和ThreadPool

    多线程原理 多线程都是基于委托的. 多线程优缺点 缺点: 1.导致程序复杂,开发调试维护困难,特别是线程交互. 2.线程过多导致服务器卡死,因为占用CPU 内存等资源. 优点: 1.良好的交互,特别对 ...

  6. 时间戳 Flume's Memory Consumption

    效率 https://www.cnblogs.com/zhujiabin/p/6168671.html?utm_source=itdadao&utm_medium=referral  http ...

  7. python 设计模式之享元(Flyweight)模式

    #写在前面 这个设计模式理解起来很容易.百度百科上说的有点绕口. #享元模式的定义 运用共享技术来有効地支持大量细粒度对象的复用. 它通过共享已经存在的对橡大幅度减少需要创建的对象数量.避免大量相似类 ...

  8. linux内核中#if IS_ENABLED(CONFIG_XXX)与#ifdef CONFIG_XXX的区别

    1. #if IS_ENABLED(CONFIG_XXX) 1.1 IS_ENABLED的定义如下: /* * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CON ...

  9. SQL-W3School-函数:SQL MIX() 函数

    ylbtech-SQL-W3School-函数:SQL MIX() 函数 1.返回顶部 1. MIN() 函数 MIN 函数返回一列中的最小值.NULL 值不包括在计算中. SQL MIN() 语法 ...

  10. Leetcode: Longest Palindromic Substring && Summary: Palindrome

    Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt ...