Page 2 of 2

Posted: Sat Jul 14, 2007 8:41 am
by chetan
why WA ???
please help

Code: Select all


CODE DELETED AFTER AC
            

Posted: Sat Jul 14, 2007 2:59 pm
by Jan
I haven't found any error. Try submitting it again.

Posted: Sat Jul 14, 2007 5:25 pm
by ayeshapakhi
>>chetan

did u really got WA??
i submitted ur code without any making change and it got ACC!!

however, remove ur code from here.. :wink:

Posted: Sat Jul 14, 2007 6:05 pm
by chetan
hmmmmmmmm............. may be i made a small change somewhere before submitting.
but anyways thanks a lot for your help
:D

Posted: Sun Aug 12, 2007 3:52 pm
by RED-C0DE
i cant understand why can not get AC in this problem...

can anyone help me or give me some I/O

here is my C0DE :


Code: Select all


//uva#865	 Substitution Cypher
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cstdio>
//#include <fstream>

using namespace std;

int main()
{
//	ifstream cin("test.in");
	char ch;
	bool newLine = false;
	int T;
	
	cin >> T;
	cin .ignore(2);
	while(T--)
	{
		if(newLine)
			cout << endl;

		string plainText="" , substitution="";
		map <char,char> mapSubst;
		getline(cin , plainText);
		
		//filling the map :
		int szPlainText = plainText.size();
		size_t inxPlainText=0;
		while(szPlainText-- && cin >> ch )
		{
			mapSubst[ plainText[inxPlainText++] ] = ch;
			cout << ch;
		}
		cout << endl << plainText << endl;

		//*** :
		getline(cin , substitution);
		while(getline(cin , substitution) && substitution!= "")
		{
			size_t szSubs= substitution.size();
			for(size_t i=0; i<szSubs; i++)
			{
				if(mapSubst.find(substitution[i])!=mapSubst.end())
					cout << mapSubst[ substitution[i] ];
				else
					cout << substitution[i];
			}

			cout << endl;
		}

		newLine =true;
	}


	return 0;
}
tank u

Re: 865 - Substitution Cypher

Posted: Thu May 28, 2009 10:11 pm
by saiful_sust
Hello RED-CODE
u programme give wa out put for
sedfcho input
try to read input from file && compare it with sedfcho output

865 - Substitution Cypher

Posted: Mon Jun 29, 2009 11:23 pm
by sazzadcsedu
nothing to display

Re: 865 - Substitution Cypher

Posted: Thu Dec 09, 2010 1:38 pm
by Shafaet_du
If you are getting a wa, try the sample input posted in 1st page.

WA: 865 - Substitution Cypher (Faiem)

Posted: Sun Apr 24, 2011 4:19 am
by faiem
Why I m getting WA.

Code: Select all

#include<stdio.h>

int main()
{
/*
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
*/
    char cyper[26]={'z','y','x','w','v','u','t','s','r',
    'q','p','o','n','m','l','k','j','i','h','g','f','e','d','c',
    'b','a'};
    char ch;
    int test,T=1;
    scanf("%d",&test);
    getchar();
    getchar();
    while(test--)
    {
        if(T>1)
            printf("\n");
        while(1)
        {
            while((ch=getchar())!='\n')
            {
                if(ch>=97&&ch<=122)
                    printf("%c",cyper[ch-97]);
                else
                    printf("%c",ch);
                }
            printf("\n");
            ch=getchar();
            if(ch=='\n'||ch==EOF)
                break;
            else
                {
                    if(ch>=97&&ch<=122)
                        printf("%c",cyper[ch-97]);
                    else
                        printf("%c",ch);
                    }
            }
        T++;
        }
    return 0;
    }

Re: 865 - Substitution Cypher

Posted: Mon Mar 17, 2014 2:45 pm
by uDebug
Here's some input / output I found useful during testing / debugging.

Input:

Code: Select all

2

abcdefghijklmnopqrstuvwxyz
mlpoknjiuhbvgytfcxdreszwaq
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Cras et mauris vestibulum, sodales erat et, dignissim urna. 
Donec ultrices dictum erat, id faucibus dui mollis auctor. 
Quisque convallis luctus nunc vitae gravida. Nullam quis orci 
eget ipsum ullamcorper consequat. Nam et bibendum elit. Proin 
sit amet congue odio. Nunc sodales vitae ligula non eleifend. 
Etiam iaculis ipsum at magna fermentum egestas. Proin quis 
felis vehicula, 

AeIoU
mPjHi
Tristique elit eget, feugiat nisi. Nullam tristique iaculis 
purus, sed laoreet sapien vestibulum vel. Quisque at 
consequat lectus. Sed posuere dignissim nulla, sit amet luctus 
ligula scelerisque non. Suspendisse eros ligula, 
ultricies in orci quis, tincidunt adipiscing neque. 
Aenean volutpat nec ipsum eget aliquam. Suspendisse potenti.
AC Output:

Code: Select all

mlpoknjiuhbvgytfcxdreszwaq
abcdefghijklmnopqrstuvwxyz
Ltxkg ufdeg otvtx dur mgkr, ptydkprkrex moufudpuyj kvur. 
Cxmd kr gmexud skdruleveg, dtomvkd kxmr kr, oujyuddug exym. 
Dtykp evrxupkd oupreg kxmr, uo nmepuled oeu gtvvud meprtx. 
Qeudcek ptysmvvud vepred yeyp surmk jxmsuom. Nevvmg ceud txpu 
kjkr ufdeg evvmgptxfkx ptydkcemr. Nmg kr lulkyoeg kvur. Pxtuy 
dur mgkr ptyjek tout. Neyp dtomvkd surmk vujevm yty kvkunkyo. 
Erumg umpevud ufdeg mr gmjym nkxgkyreg kjkdrmd. Pxtuy ceud 
nkvud skiupevm, 

mPjHi
AeIoU
TristiquP Plit PgPt, fPugiat nisi. Nullam tristiquP iaculis 
purus, sPd laHrPPt sapiPn vPstibulum vPl. QuisquP at 
cHnsPquat lPctus. SPd pHsuPrP dignissim nulla, sit amPt luctus 
ligula scPlPrisquP nHn. SuspPndissP PrHs ligula, 
ultriciPs in Hrci quis, tincidunt adipiscing nPquP. 
mPnPan vHlutpat nPc ipsum PgPt aliquam. SuspPndissP pHtPnti.

Re: WA: 865 - Substitution Cypher (Faiem)

Posted: Mon Mar 17, 2014 2:49 pm
by uDebug
faiem wrote:Why I m getting WA.
Try running your code on the input I just now posted.

Re: 865 - Substitution Cypher

Posted: Thu Feb 12, 2015 2:28 am
by unreleased
why WA??

Code: Select all

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <map>
#include <set>
#include <sstream>
#include <utility>
#include <bitset>

#define mx 1000000
#define INT 2147483647

#define D   double
#define L   long
#define LL  long long
#define ULL unsigned long long

#define isc1(a)      scanf("%d", &a)
#define isc2(a,b)    scanf("%d%d", &a, &b)
#define isc3(a,b,c)  scanf("%d%d%d", &a, &b, &c)
#define llsc1(a)     scanf("%I64d", &a)
#define llsc2(a,b)   scanf("%I64d%I64d", &a, &b)
#define llsc3(a,b,c) scanf("%I64d %I64d %I64d", &a,&b,&c)

#define f(a,n)  for(a=0; a<n; a++)
#define all(a)  a.begin(), a.end()
#define ms(arr) memset(arr, 0, sizeof(arr))
#define cl(a)   a.clear()
#define sz(a)   a.size()

#define sc scanf
#define pf printf
#define pu push_back
#define pb pop_back
#define vc vector
#define mp make_pair
#define fi first
#define se second
#define pip pf("pip.....\n")

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    int a,b,c, d;

    string str,temp, from, to;
    int len, tst, arr[250];
    isc1(tst); getchar(); getchar(); c=0;
    while(tst--)
    {
        if(c)pf("\n\n");c=1;

        cin>>from>>to;  getchar();
        cout<<to<<"\n"<<from<<"\n";

        ms(arr);
        for(a=0; a<=sz(from); a++) arr[from[a]]=(int) to[a];

        d=0;
        while(getline(cin, str))
        {

            len=sz(str);
            if(len && d)pf("\n"); d=1;
            if(len==0) break;

            for(a=0; a<len; a++)
            {
                //if(str[a]=='\0'){pf("\n");continue;}

                if(arr[str[a]])pf("%c", arr[str[a]]);
                else pf("%c", str[a]);
            }


        }

    }

    return 0;
}

Re: 865 - Substitution Cypher

Posted: Thu Feb 12, 2015 10:37 pm
by brianfry713
Always print a newline char at the end of the last line.

Re: 865 - Substitution Cypher

Posted: Fri Feb 13, 2015 5:02 am
by unreleased
brianfry713 wrote:Always print a newline char at the end of the last line.
aah its WA too after adding a newline at the end :( ....

Code: Select all

        #include <iostream>
        #include <cstdio>
        #include <string>
        #include <cstring>
        #include <cmath>
        #include <vector>
        #include <stack>
        #include <queue>
        #include <algorithm>
        #include <iterator>
        #include <map>
        #include <set>
        #include <sstream>
        #include <utility>
        #include <bitset>

        #define mx 1000000
        #define INT 2147483647

        #define D   double
        #define L   long
        #define LL  long long
        #define ULL unsigned long long

        #define isc1(a)      scanf("%d", &a)
        #define isc2(a,b)    scanf("%d%d", &a, &b)
        #define isc3(a,b,c)  scanf("%d%d%d", &a, &b, &c)
        #define llsc1(a)     scanf("%I64d", &a)
        #define llsc2(a,b)   scanf("%I64d%I64d", &a, &b)
        #define llsc3(a,b,c) scanf("%I64d %I64d %I64d", &a,&b,&c)

        #define f(a,n)  for(a=0; a<n; a++)
        #define all(a)  a.begin(), a.end()
        #define ms(arr) memset(arr, 0, sizeof(arr))
        #define cl(a)   a.clear()
        #define sz(a)   a.size()

        #define sc scanf
        #define pf printf
        #define pu push_back
        #define pb pop_back
        #define vc vector
        #define mp make_pair
        #define fi first
        #define se second
        #define pip pf("pip.....\n")

        using namespace std;

        int main()
        {
            //freopen("input.txt", "r", stdin);
            int a,b,c, d;

            string str,temp, from, to;
            int len, tst, arr[250];
            isc1(tst); getchar(); getchar(); c=0;
            while(tst--)
            {
                //if(c)puts("");c=1;

                cin>>from>>to;  getchar();
                cout<<to<<"\n"<<from<<"\n";

                ms(arr);
                for(a=0; a<=sz(from); a++) arr[from[a]]=(int) to[a];

                d=0;
                while(getline(cin, str))
                {

                    len=sz(str);
                    //if(len && d)pf("\n"); d=1;
                    if(len==0) break;

                    for(a=0; a<len; a++)
                    {
                        //if(str[a]=='\0'){pf("\n");continue;}

                        if(arr[str[a]])pf("%c", arr[str[a]]);
                        else pf("%c", str[a]);
                    }
                    puts("");

                }
                puts("");

            }

            return 0;
        }