[Week6 limit of analog master the magic の stuff II]

Subject description:

A × B stuff there playing cards. Each playing card has a size (an integer, denoted by a, the range is 0 to section A - 1) and a color (integer, denoted is b, the range interval is 0 to B - 1.

Poker is different from each other, that is unique, that no two cards are the same size and color.

"Hand" means that your hands are five different cards, five cards no points after the order of who is who in front, they form a card type. We define nine card type, the following are nine kinds of card type of rule, we use "low-order priority" to match the card type, that is, this "hand" on a card-type rule is from top to bottom to meet its "brand type number" (an integer belonging 1-9):

1, Flush: meet Rule 5 and Rule 4.
2. bomb: 5 cards which is equal to four card size.
3, three with two: five cards which is equal to three cards sizes, and additionally 2 card size are equal.
4, flush: 5 cards of the same suit is
5, straight: 5 cards of the size of the form x, x + 1, x + 2, x + 3, x + 4.
6, three: 5 cards which is equal to three cards size.
7, two pairs: 5 cards which is equal to two card size, and the other three cards in equal two card size.
8, a pair of : 5 cards which is equal to the size of two cards.
9, to afford: the hand does not satisfy any of a card type.

Now, Eastern took two cards from the playing cards A × B! Are (a1, b1) and (a2, b2). (Where a represents the magnitude, b represents color)

Now from the rest of the playing cards randomly out of three! The composition of hand! !

In fact, in addition to the stuff (an integer code that will be playing, amateur he was a magician, and now he wants to predict the likelihood of his future, namely the possibility that he will get the "hand", we use a "card-type number belonging 1-9) "to represent the hand of the card type, then his nine possible future, but each number of possible solutions is not the same.

Now, Ago motorcycle Eye stuff is gone, you need to help him do the math nine kinds of card type, the program number of each type of card.

Input Format

Line 1 contains the integers A and B (5 ≤ A ≤ 25, 1 ≤ B ≤ 4).
Line 2 contains the integers a1, b1, a2, b2 ( 0 ≤ a1, a2 ≤ A - 1, 0 ≤ b1 , b2 ≤ B - 1, ( a1, b1) ≠ (a2, b2)).

Output Format

Output line, this line has nine integers, each integer represents the number nine card type of program (by card type numbers in ascending order)

Sample

Sample Input1

5 2
1 0 3 1

Sample Output1

0 0 0 0 8 0 12 36 0

Sample Input2

25 4
0 0 24 3

Sample Output2

0 2 18 0 0 644 1656 36432 113344

Thinking

According to the meaning of problems, it is to use already get the hand of two cards and the remaining cards are combined to form a five card after card type identification number to get a different type of card the respective number of possibilities. The approach here is to place the remaining cards type them into an array, then the array to search, each card has two choices, checked or unchecked, this can traverse to type all the cards combined. If you select to meet the five cards, the card type to judge them, corresponding to the number of records to +1 card type.

Reflection

For the first time do not realize when the problem is a search problem, but chose to use a combination of several approaches, ideas were calculated using the number of permutations and combinations of the corresponding card type, card type but different to the number of combinations of repeated calculations overhead resulting program is relatively large, but also to meet the low-order priority this condition, so that the follow-up to determine the conditions of the license type become jumbled.
Also when you see the "low-order priority" this condition, we expect to deal with a hand to judge from the number of low cards to high-order-type card type, so it should be on the card type enumeration, enumeration judge the results before I realize that this is a type of search topics, so choose the algorithm described above.

Code

#include <iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<vector>
using namespace std;
const int A=26,B=4;
int a,b,sum;
int note[10];
struct poker{
	int value;int color;
	bool operator<(poker&b)
	{
		return value<b.value;
	}
};
poker vis[A*B+5];
vector<poker> arr;
void judge(vector<poker>&arr)
{
	vector<poker>temp=arr;
	sort(temp.begin(),temp.end());
	bool flag1=false,flag2=false;
	if(temp[0].value+1==temp[1].value&&temp[1].value+1==temp[2].value
	&&temp[2].value+1==temp[3].value&&temp[3].value+1==temp[4].value)
		flag2=true;
	if(temp[0].color==temp[1].color&&temp[1].color==temp[2].color
	&&temp[2].color==temp[3].color&&temp[3].color==temp[4].color)
		flag1=true;
	if(flag1&&flag2)
	{
		note[1]++;return;
	}
	if(temp[4].value==temp[1].value||temp[0].value==temp[3].value)
	{
		note[2]++;return;
	}
	if((temp[2].value==temp[0].value&&temp[3].value==temp[4].value)
	||(temp[4].value==temp[2].value&&temp[0].value==temp[1].value))
	{
		note[3]++;return;
	}
	if(flag1)
	{
		note[4]++;return;
	}
	if(flag2)
	{
		note[5]++;return;
	}
	if(temp[0].value==temp[2].value||temp[1].value==temp[3].value||temp[2].value==temp[4].value)
	{
		note[6]++;return;
	}
	if((temp[0].value==temp[1].value&&(temp[2].value==temp[3].value||temp[3].value==temp[4].value))
	||(temp[1].value==temp[2].value&&temp[3].value==temp[4].value))
	{
		note[7]++;return;
	}
	if(temp[0].value==temp[1].value||temp[1].value==temp[2].value
	||temp[2].value==temp[3].value||temp[3].value==temp[4].value)
	{
		note[8]++;return;
	}
	note[9]++;return;
}
void solve(int i,vector<poker>&arr)
{
	if(arr.size()==5)
	{
		judge(arr);
		return;	
	}
	if(i<sum)
	{
		solve(i+1,arr);
		arr.push_back(vis[i]);
		solve(i+1,arr);
		arr.pop_back();
	}
}
int main()
{
	scanf("%d%d",&a,&b);
	memset(note,0,sizeof(note));
	int temp1,temp2,temp3,temp4;
	scanf("%d%d%d%d",&temp1,&temp2,&temp3,&temp4);
	arr.push_back({temp1,temp2});
	arr.push_back({temp3,temp4});
	sum=0;
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)
		{
			if((i!=temp1||j!=temp2)&&(i!=temp3||j!=temp4))
			{
				vis[sum]={i,j};
				sum++;
			}
		}
	}
	solve(0,arr);
	for(int i=1;i<9;i++)
		printf("%d ",note[i]);
	printf("%d\n",note[9]);
	return 0;
}
Published 24 original articles · won praise 8 · views 524

Guess you like

Origin blog.csdn.net/weixin_44034698/article/details/105160500