Page 1 of 1

12491 - Words

Posted: Sun Nov 25, 2012 10:16 pm
by uvasarker
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;
}


Re: 12491 Words

Posted: Fri Nov 30, 2012 9:36 am
by brianfry713
Input:
1 1
0
1
AC output:
N