Thanks wook!

But your case is considered in my parse input method.

Sorry but have posted my code.

I'm getting RE and can't find any bug.

Could you say me if my parse input method is wrong?

Code: Select all

```
struct stmv {int x,y;};
stmv movs[256];
char s1[30000], s2[30000], s[30000], m[30][30];
main ()
{
int x, y, H, W, len1, len2, i, cases, kase;
movs['E'].x=0, movs['E'].y=1;
movs['W'].x=0, movs['W'].y=-1;
movs['N'].x=-1, movs['N'].y=0;
movs['S'].x=1, movs['S'].y=0;
gets(s);
sscanf(s,"%d",&cases);
for (kase=1; kase<=cases; kase++)
{
gets(s);
sscanf(s,"%d%d",&H,&W);
for (i=0; i<H; i++) gets(m[i]);
gets(s);
sscanf(s,"%d%d%d",&len1,&x,&y);
x--, y--;
gets(s);
for (i=0; i<len1; i++)
{
// With this small assert I get: Runtime Error (SIGABRT)
assert(x>=0 && y>=0);
s1[i]=m[x][y];
x+=movs[s[i]].x;
y+=movs[s[i]].y;
}
s1[len1++]=m[x][y];
s1[len1]=0;
gets(s);
sscanf(s,"%d%d%d",&len2,&x,&y);
x--, y--;
gets(s);
for (i=0; i<len2; i++)
{
// With this small assert I get: Runtime Error (SIGABRT)
assert(x>=0 && y>=0);
s2[i]=m[x][y];
x+=movs[s[i]].x;
y+=movs[s[i]].y;
}
s2[len2++]=m[x][y];
s2[len2]=0;
int n=LCS(s1,s2);
cout << "Case " << kase << ": " << len1-n << " " << len2-n << "\n";
}
}
```

Thanks!