Poj 2192 zipper, poj2192zipper

Source: Internet
Author: User
Tags modulus

Poj 2192 zipper, poj2192zipper

Today, I suddenly found out that I was not very impressed with this question, but I thought it was a classic question. So I decided to write a conclusion report.

The first question is to give you three strings. The first two strings can be constructed.
But you need to know that this condition is
They cannot change the order of the two final strings. </p> <p> two state equations are obtained.
Dp [I] [j] indicates whether the first I character and the first j character constitute the first I + j characters of s3
(1)dp[i][j]=(dp[i-1][j]&&s1[i]==s3[i+j])?ture:flase
(2)dp[i][j]=(dp[i][j-1]&&s2[j==s3[i+j])?true:flase
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;char s1[500],s2[500],s3[500];int dp[500][500];int main(){    int t,i,j,k,len1,len2,len3,cas = 1 ;    scanf("%d",&t);    while(t--)    {        scanf("%s%s%s",s1+1,s2+1,s3+1);        len1 = strlen(s1+1);        len2 = strlen(s2+1);        len3 = strlen(s3+1);        memset(dp,0,sizeof(dp));        for(i = 1; i<=len1; i++)        {            if(s1[i] == s3[i])                dp[i][0] = 1;            else break;        }        for(i = 1; i<=len2; i++)        {            if(s2[i] == s3[i])                dp[0][i] = 1;            else break;        }        for(i = 1; i<=len1; i++)        {            for(j = 1; j<=len2; j++)            {                if(s3[i+j] == s1[i] && dp[i-1][j])                    dp[i][j] = 1;                if(s3[i+j] == s2[j] && dp[i][j-1])                    dp[i][j] = 1;            }        }        printf("Data set %d: ",cas++);        if(dp[len1][len2])            printf("yes\n");        else            printf("no\n");    }    return 0;}



Categories of topics on acm

Let me have a look at this information.
Peking University ACM (PKU JudgeOnline) subject category
1. Search // trace back
2. DP (Dynamic Planning)
3. Greedy
4. Graph Theory // Dijkstra, Minimum Spanning Tree, and network stream
5. Number Theory // solves the modulus linear equation
6. Calculate the area and perimeter of the joint of the geometric/Convex Shell with the same placement of the rectangle
7. Composite math // Polya Theorem
8. Simulation
9. Data Structure // check the collection and heap
10. Game Theory
1. Sorting
1423,169 4, 1723,172 7, 1763,178 8, 1828,183 8, 1840,220 1, 2376,237 7, 2380,131 8, 1877,192, 1971,

1974,199 0, 2001,200 2, 2092,237 9,
1002 (character processing is required, and sorting can be done in a fast way) 1007 (stable sorting) 2159 (difficult to understand) 2231 2371 (simple sorting)

2388 (sequential statistics algorithm) 2418 (Binary sorting tree)
2. Search, backtracking, and traversal
1022 1111d 1118 1129 1190 1562 1564 1573 1655 2184 2225 2243 2312 2362 2378 2386

1010,1011, 1018,1020, 1054,1062, 1256,1321, 1363,1501, 1650,1659, 1664,1753, 2078
, 2083,2303, 2310,2329
Simple: 1128,116 6, 1176,123 1, 1256,127 0, 1321,154 3, 1606,166 4, 1731,174 2, 1745,184 7, 1915,195 0,

2038,215 7, 2182,218 3, 2381,238 6, 2426,
Not easy: 1024,105 4, 1117,116 7, 1708,174 6, 1775,187 8, 1903,196 6, 2046,219 7, 2349,
Recommended: 1011,119 0, 1191,141 6, 1579,163 2, 1639,165 9, 1680,168 3, 1691,170 9, 1714,175 3, 1771,182 6,

1855,185 6, 1890,192 4, 1935,194 8, 1979,198 0, 2170,228 8, 2331,233 9, 2340,1979 (similar to the maze) 1980 (for pruning

High requirements)
3. Calendar
1008 2080 (Be careful with such questions)
4. Enumeration
1387,141, 2245,232, 2363,238 1, 1650 6, (high requirements for pruning), (decimal precision Problem

)
5. Typical data structure Algorithms
Easy: 1182,165 6, 2021,202 3, 2051,215 3, 2227,223 6, 2247,235 2, 2395,
Not easy: 1145,117 7, 1195,122 7, 1661,183 4,
Recommendation: 1330,133 8, 1451,147 0, 1634,168 9, 1693,170 3, 1724,198 8, 2004,201 0, 2119,227 4, 1125

Method), 2421 (Minimum Spanning Tree of the graph)
6. Dynamic Planning
... The remaining full text>

ACM solution report

Category of a poj question
Mainstream algorithms:
1. Search // trace back
2. DP (Dynamic Planning)
3. Greedy
4. Graph Theory // Dijkstra, Minimum Spanning Tree, and network stream
5. Number Theory // solves the modulus linear equation
6. Calculate the area and perimeter of the joint of the geometric/Convex Shell with the same placement of the rectangle
7. Composite math // Polya Theorem
8. Simulation
9. Data Structure // check the collection and heap
10. Game Theory
1. Sorting
1423,169 4, 1723,172 7, 1763,178 8, 1828,183 8, 1840,220 1, 2376,
2377,238 0, 1318,187 1971,197, 1990,200 4, 2002,209 1, 2379 2,
1002 (character processing is required, and sorting can be done in a fast way) 1007 (stable sorting) 2159 (difficult to understand)
2231 2371 (simple sorting) 2388 (sequence statistics algorithm) 2418 (Binary sorting tree)
2. Search, backtracking, and traversal
2329
Simple: 1128,116 6, 1176,123 1, 1256,127 0, 1321,154 3, 1606,166 4,
1731,174 2, 1745,184, 1950,203, 2157,218 8, 2183,238 2, 2386,242 1, 6
Not easy: 1024,105 4, 1117,116 7, 1708,174 6, 1775,187 8, 1903,196 6, 2046,
2197,234 9
Recommended: 1011,119 0, 1191,141 6, 1579,163 2, 1639,165 9, 1680,168 3, 1691,
1709,171 4, 1753,1771, 1826,185 5, 1856,189 0, 1924,193 5, 1948,197 9, 1980,217 2331,233 1979, 1980 9, (similar to the maze), (higher requirements for pruning)
3. Calendar
1008 2080 (Be careful with such questions)
4. Enumeration
1387,141, 2245,232, 2363,238 1, 1650 6, (higher pruning requirements), (decimal precision problem)
5. Typical data structure Algorithms
Easy: 1182,165 6, 2021,202 3, 2051,215 3, 2227,223 6, 2247,235 2,
2395
Not easy: 1145,117 7, 1195,122 7, 1661,183 4
Recommended: 1330,133 8, 1451,147 0, 1634,168 9, 1693,170 3, 1724,198 8, 2004,
2010,211 9, 2274
1125 (fresh algorithm), 2421 (Minimum Spanning Tree of the graph)
6. Dynamic Planning
1037 A decorative fence,
1050 To the Max,
1088 skiing,
1125 Stockbroker Grapevine,
1141 Brackets Sequence,
1159 Palindrom ...... remaining full text>

Related Keywords:

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.