## 12491 - Words

All about problems in Volume 124. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

### 12491 - Words

I am getting WA. in this problem.......Please, help me
My Code:

Code: Select all

``````#include <cstdio>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <iterator>
#include <iostream>
using namespace std;

int main()
{
map<int,string>str1, str2;
map<int,string>::iterator it, bb, ee;
string s1("\0"), s2("\0"), tmp, t1("\0"), t2("\0");
int n1, n2;
//freopen("in-12491.txt","r",stdin);
while(scanf("%d %d",&n1,&n2)==2){
int ln1=0, ln2=0;
for(int i=0 ; i<n1 ; i++){
cin>>tmp;
str1[i]=tmp;
s1 = s1 + tmp;
tmp.clear();
}
for(int i=0 ; i<n2 ; i++){
cin>>tmp;
str2[i]=tmp;
s2 = s2 + tmp;
tmp.clear();
}
if(n1==n2){
printf("S\n");
}
else{
int fag=0;
while(ln1<=n1 || ln2<=n2){
t1 = t1 + str1[ln1++];
t2 = t2 + str2[ln2++];
if(t1==t2){
fag=1;
printf("S\n");
break;
}
}
if(fag==0)
printf("N\n");
}
s1.clear(); s2.clear(); t1.clear(); t2.clear();
}
return 0;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 12491 Words

Input:
1 1
0
1
AC output:
N
Check input and AC output for thousands of problems on uDebug!