题目链接:https://codeforces.com/contest/1230/problem/C 思路:暴搜,,,,赛后一遍过,为啥当时没想到。 1 #includeiostream 2 #includecstdio 3 #includectime 4 #includecstring 5 #includecstdlib 6 #includecmath 7 #in
题目链接:https://codeforces.com/contest/1230/problem/C
思路:暴搜,,,,赛后一遍过,为啥当时没想到。
1 #include<iostream> 2 #include<cstdio> 3 #include<ctime> 4 #include<cstring> 5 #include<cstdlib> 6 #include<cmath> 7 #include<queue> 8 #include<stack> 9 #include<map> 10 #include<algorithm> 11 #define Max(a,b) ((a)>(b)?(a):(b)) 12 #define Min(a,b) ((a)<(b)?(a):(b)) 13 #define Mem0(x) memset(x,0,sizeof(x)) 14 #define Mem1(x) memset(x,-1,sizeof(x)) 15 #define MemX(x) memset(x,0x3f,sizeof(x)) 16 using namespace std; 17 typedef long long ll; 18 const int inf=0x3f3f3f; 19 const double pi=acos(-1.0); 20 21 int cnt[30][30]; 22 struct node{ 23 int x,y; 24 bool flag; 25 }edge[30]; 26 27 void init() 28 { 29 memset(cnt,0,sizeof(cnt)); 30 for (int i=1;i<=6;i++){ 31 for (int j=i;j<=6;j++){ 32 cnt[i][j]++; 33 } 34 } 35 return ; 36 } 37 int node1[20],n,m,ans; 38 void dfs() 39 { 40 init(); 41 node edge1[30]; 42 for (int i=1;i<=m;i++){ 43 edge1[i].x=edge[i].x; 44 edge1[i].y=edge[i].y; 45 edge1[i].flag=false; 46 } 47 int tmp=0; 48 for (int i=1;i<=m;i++){ 49 if (cnt[node1[edge1[i].x]][node1[edge1[i].y]]>0){ 50 cnt[node1[edge1[i].x]][node1[edge1[i].y]]--; 51 tmp++; 52 } 53 } 54 ans=max(tmp,ans); 55 return ; 56 } 57 void find(int pos) 58 { 59 if (pos==n+1){ 60 dfs(); 61 return ; 62 } 63 for (int i=1;i<=6;i++){ 64 node1[pos]=i; 65 find(pos+1); 66 } 67 return ; 68 } 69 int main() 70 { 71 ans=0; 72 cin>>n>>m; 73 for (int i=1;i<=m;i++){ 74 cin>>edge[i].x>>edge[i].y; 75 if (edge[i].x>edge[i].y){ 76 int temp=edge[i].x; 77 edge[i].x=edge[i].y; 78 edge[i].y=temp; 79 } 80 } 81 find(0); 82 cout<<ans<<endl; 83 return 0; 84 }