CF1210A Anadi and Domino

Posted wangyiming

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF1210A Anadi and Domino相关的知识,希望对你有一定的参考价值。

思路:

很有意思的思维题。

实现:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int check(vector<int>& v, set<pair<int, int>>& st)
 4 
 5     int res = 0;
 6     map<pair<int, int>, int> mp;
 7     for (int i = 1; i <= 6; i++)
 8     
 9         for (int j = i; j <= 6; j++)
10         
11             mp[make_pair(i, j)] = 0;
12         
13     
14     for (auto it: st)
15     
16         int a = v[it.first - 1], b = v[it.second - 1];
17         pair<int, int> tmp(min(a, b), max(a, b));
18         if (mp[tmp] == 0)
19         
20             mp[tmp] = 1; res++;
21         
22     
23     return res;
24 
25 int main()
26 
27     int n, m, a, b;
28     while (cin >> n >> m)
29     
30         set<pair<int, int>> st;
31         for (int i = 0; i < m; i++)
32         
33             cin >> a >> b;
34             st.insert(make_pair(min(a, b), max(a, b)));
35         
36         if (n <= 6)  cout << m << endl; continue; 
37         vector<int> a1, 1, 2, 3, 4, 5, 6;
38         int maxn = 0;
39         do
40         
41             maxn = max(maxn, check(a, st));
42          while (next_permutation(a.begin(), a.end()));
43         cout << maxn << endl;
44     
45     return 0;
46 

以上是关于CF1210A Anadi and Domino的主要内容,如果未能解决你的问题,请参考以下文章

588 div2 C. Anadi and Domino

Anadi and Domino

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

(CF#257)B. Jzzhu and Sequences

CF | Alyona and Numbers

Vika and Segments - CF610D