HDU 1523 Decoding Morse Sequences (DP)

Source: Internet
Author: User
Tags bitset

HDU 1523 Decoding Morse Sequences (DP)

Question: Give an encoding, give n words to the dictionary, and find the number of words in the dictionary that can be compiled into the given encoding.

Idea: there are a large number of answers, so it is not difficult to think of dynamic planning. D [I] indicates the number of answers until the I encoding. Then, the starting point is d [0] = 1. We enumerate the encoding of n words in the second loop, if yes, it will be transferred.

For details, see the code:

#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<string>#include<vector>#include<stack>#include<bitset>#include<cstdlib>#include<cmath>#include<set>#include<list>#include<deque>#include<map>#include<queue>#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))using namespace std;typedef long long ll;const double PI = acos(-1.0);const double eps = 1e-6;const int mod = 1000000000 + 7;const int INF = 1000000000;const int maxn = 10000 + 10;int T,n,m,d[maxn];char table[26][10] = {{".-"},{"-..."},{"-.-."},{"-.."},{"."},{"..-."},{"--."},{"...."},{".."},{".---"},{"-.-"},{".-.."},{"--"},{"-."},{"---"},{".--."},{"--.-"},{".-."},{"..."},{"-"},{"..-"},{"...-"},{".--"},{"-..-"},{"-.--"},{"--.."}};char buf[maxn][105], s[maxn], str[30];int main() {    scanf("%d",&T);    while(T--) {        scanf("%s%d",s,&n);        for(int i=0;i<n;i++) int="" len="strlen(str);" j="0;j<len;j++)" i="0;i<len;i++)" a="strlen(buf[j]);" return="" pre=""><p></p></n;i++)></queue></map></deque></list></set></cmath></cstdlib></bitset></stack></vector></string></iostream></algorithm></cstring></cstdio>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.