Regionals 2006 >> Europe-northeastern
Problem Link: UVA1588 UVALive3712 POJ3158 kickdown. Basic Training level problem, programming in C language.
Problem brief: (slightly).
The question to note is which of the two strings is possible on the left.
In the program, the cyclic control conditions need to be handled with care.
the C language Program of AC is as follows:
/* UVA1588 UVALive3712 POJ3158 kickdown */#include <stdio.h> #include <string.h> #define MIN (x, Y) (((x) > (y ))? (y):(x)) #define MAXN 100char S[MAXN], t[maxn];int main (void) {int slen, Tlen, ans1, Ans2, I, J; while (scanf ("%s", s)! = EOF) {scanf ("%s", T); Slen = strlen (s); Tlen = strlen (t); /* s left, t right */for (i=0; i<slen; i++) {for (j=0; J<tlen && i+j<slen; j + +) { if (s[i+j] = = ' 2 ' && t[j] = = ' 2 ') break; } if (j = = Tlen | | i+j = = slen) break; } ans1 = i + tlen; if (Ans1 < Slen) ans1 = Slen; /* t left, s right */for (j=0; j<tlen; J + +) {for (i=0; I<slen && j+i<tlen; i++) { if (t[j+i] = = ' 2 ' && s[i] = = ' 2 ') break; } if (i = = Slen | | j+i = = tlen) break; } Ans2 = j + Slen; if (Ans2 < Tlen) Ans2 = Tlen; printf ("%d\n", MIN (ans1, ans2)); } return 0;}
UVA1588 UVALive3712 POJ3158 Kickdown