Page 1 of 2

391 - Mark-up .... help !

Posted: Fri Jul 12, 2002 1:29 pm
by Dominik Michniewski
Could anyone give me any special cases for this problem ?
I use finite state machine to solve this question, but stil got WA ....

Is any other trick than I have to print "34" where I found "\s1.234" ??
And what should I print where I found "\S1.123" ??

Posted: Tue Aug 13, 2002 9:58 pm
by L33T Magus
Did you remember that if the input text ends with a '\' it needs to be printed?

Posted: Tue Aug 13, 2002 11:02 pm
by Dominik Michniewski
Yes, I remember it .....
But if input looks like

A\
B\

should I print

A\
B\

or
A
B\
?????????????????????????

Posted: Sat Aug 24, 2002 7:39 am
by arc16

Code: Select all

Is any other trick than I have to print "34" where I found "\s1.234" ?? 
And what should I print where I found "\S1.123" ??
output should be nothing for \s1.234 and and "S1.123"
some tricky case i know is :

Code: Select all

input:
\s3.4a\sb\s.5c\s100.d\s12e
\**\\***\\*\*\*

output:
abcde
*\**\*
also don't forget that you don't have to reset the control/mark-up flag on each line (this is where i failed before i got AC)

Posted: Tue Aug 27, 2002 9:18 am
by Dominik Michniewski
I don't know what's wrong with this code ....
I got the same result as you, arc16, but still WA
could anyone help me ?

Dominik
------------------------------

Code: Select all

I cut off the code, because it was a solution after some modifications ;-)

Posted: Tue Aug 27, 2002 9:55 am
by arc16
Dominik Michniewski wrote:I don't know what's wrong with this code ....
I got the same result as you, arc16, but still WA
could anyone help me ?
haven't take a deep look at your program, but my guess is that
your program cannot process either a sequencing '\' and '*' characters correctly. Check out the following test case:

Code: Select all

input:
\**\\***\\*\*\*
\*
\\
\*
\\ \a\b\c\d\e\f\g\\h\\\*

your output:
*\**\*

\\

\ \a\c\d\e\f\g\h\

correct output:
*\**\*

\\

\ acdefg\h\
see? in the last line, the mark-up control in your program is curreny off, while it should be on. Try to do some more testing with something like \**\\\\\\\\\\\\\\\\\***********\*\*\\*\***\\****\\\*\*\*\*\a\c

good luck :D

Posted: Mon Sep 23, 2002 10:30 am
by Dominik Michniewski
Thanks all for helping me :-)
I got Acceoted now :-)

arc16: thank you very much for very usefull test cases and hints :-))

Dominik

Posted: Fri Feb 28, 2003 11:14 pm
by yahoo
I cant understan how the output for \\ be \\. From the problem description it is clear that \\ will be replaced by \.
from problem:
the mark-up \\ can be used to print a single \.
will anybody please help. I am getting wrong answer all the time. :oops: :oops: :oops:

Posted: Sat Mar 01, 2003 4:00 am
by Red Scorpion
Consider This sample:

:lol:

Code: Select all

Sample Input
LSKD AODP.
\\ akdf \\
\* asifj \\ \\\
\\\\
\\ askf asf\afa\
\*  \\ \bisjaf

Output:
LSKD AODP.
\ akdf \
 asifj \\ \\\
\\\\
\\ askf asf\afa\
  \ isjaf
Did You see the difference?
when the input is "\\" You should print the "\" when the toggle processing of mark-ups on;
otherwise you should print exactly as they appear in the input.

Note:
At the start, processing of mark-ups should be on.
RS. :lol:

Posted: Sun Mar 02, 2003 10:30 pm
by yahoo
Thanks for your reply. My program matches with all the input and output of yours. Will anybody kindly see my program and tell me where i am wrong. Here is my code:

Code: Select all

#include <stdio.h>
#include <string.h>

main()
{
	char a[10000];
	int flag1,flag2,flag3,flag4,i,j,l1;	
	while(1)
	{
		if(gets(a)==NULL) break;
		l1=strlen(a);
		flag1=flag2=flag3=0;
		for(i=0;i<l1;i++)
		{
			if(a[i]=='\\')
			{
				if(a[i+1]=='b'&&flag4!=0) {i++;flag1=1;}
				else if(a[i+1]=='s'&&flag4!=0)
				{
					flag2=1;
					for(j=i+2;;j++)
						if(!((a[j]>='0' && a[j]<='9')||a[j]=='.')) break; ;
					i=j-1;
				}
				else if(a[i+1]=='*')
				{
					i++;
					if(flag4==0) flag4=1;
					else flag4=0;

				}
				else if(a[i+1]=='\\'&&flag4!=0)
				{
					i++;
					printf("\\");
				}
				else if (flag4==0) printf("%c",a[i]);
			}
			else printf("%c",a[i]);
		}
		printf("\n");
	}
	return 0;
}
Thanks in advance.


Posted: Mon Mar 03, 2003 7:41 am
by anupam

if there be space charecter after the mark up off,
will i print it or not..
i found the problem harder then i guessed before..
-- if the mark up command is off then all the charecters get printed or not..
if yes then the code of yahoo has no mistakes i think...
--if no please reply why?
--anupam

Posted: Tue May 24, 2005 3:17 pm
by N|N0
I've no idea why this does not work :-?

Code: Select all

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define ON 1
#define OFF 0

int main(void) {
  char vrsta[100000];
  char *p;
  int process = ON, pika, prva = 1;
  while (!feof(stdin)) {
    gets(vrsta);
    p = vrsta;
    if (!prva) putchar('\n'); else prva = 0;
    while (*p != '\0') {
      if (*p == '\\') {
        if (*(p+1) == 'b' && process) {
          p+=2;
        } else if (*(p+1) == 'i' && process) {
          p+=2;
        } else if (*(p+1) == '*') {
          process = (process==ON)?OFF:ON;
          p+=2;
        } else if (*(p+1) == 's' && process) {
          p+=2;
          pika = 0;
          while (isdigit(*p) || (*p == '.' && !pika)) {
            if (*p == '.') pika++;
            p++;
          }
        } else {
          if (!process) {
            putchar(*p);
            p++;
          } else {
            if (*(p+1) != '\0') {
              p++;
              putchar(*p);
              p++;
            } else {
             p++;
             putchar('\\');
            } 
          }
        }
      } else {
        putchar(*p);
        p++;
      }
    }
  }
  return(0);
}
Any suggestion?

391 - Mark-up

Posted: Wed Jul 27, 2005 1:10 pm
by Navid666
remove after accept!

Posted: Mon Aug 01, 2005 1:55 pm
by Navid666
is any body there???....please help me this is very easy problem and i dont know why i got WA?????????????????? :(:((:(

May this helps you !

Posted: Sun Aug 07, 2005 2:40 pm
by hyperion
Hi Navid,

Test this input to your program, it should generate the output
below which my Accepted Code generated.
Hope you figure out your problem with this test cases. :D

Input :

\s3.4a\sb\s.5c\s100.d\s12e
\*\b no translation should occur *\\ \b*\s3.*\*
/i/b/s\bb\ii\ss
\**\\***\\*\*\*
\*
\\
\*
\\ \n\o\ \p\r\ob\l\e\m\*s\*
\* close literal text by end-of-file\

Desired Output :

abcde
\b no translation should occur *\\ \b*\s3.*
/i/b/sbis
*\**\*

\\

\ no problems
close literal text by end-of-file\