11220 - Decoding the message.
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11220 - Decoding the message
Doesn't match the sample I/O
Check input and AC output for thousands of problems on uDebug!
Re: 11220 - Decoding the message
Look into the C++ function "getline" instead of using the deprecated function "gets". It's probably worth learning about.Shihab wrote:WA help
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11220 - Decoding the message
I am getting RTE, but I don't understand why. Please, help me. Whats wrong with my code?

Code: Select all
Removed getting AC


Last edited by Shahidul.CSE on Sun Aug 24, 2014 4:54 pm, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Re: 11220 - Decoding the message
Increase array limit toJan wrote:Read the description again...
So, 30*30 = 900 letters and with some white spaces you have almost 1000 characters in a line. But you have only 109 characters. For safety take 2000 or more.each line is composed by 1 ? M ? 30 words. Two words in the same line are separated by one or more white spaces. A word is formed by the letters A-Z and a-z and has at most 30 letters
Hope it helps.
Code: Select all
char words_in_lines[1000];
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11220 - Decoding the message
thanks, got accepted.



Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
11220 - Decoding the message.
I keep getting WA and I could not find anything wrong with my code!
REMOVED after AC.
Issue: New line between cases!
REMOVED after AC.
Issue: New line between cases!
Last edited by mjimaz on Sun Dec 07, 2014 4:56 pm, edited 1 time in total.
Re: 11220 - Decoding the message.
Use code tags. Change input parsing. Print a blank line between each test case.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 11220 - Decoding the message.
Thanks lighted.
-
- New poster
- Posts: 5
- Joined: Tue Apr 07, 2015 11:10 am
Re: 11220 - Decoding the message.
I keep getting WA and I could not find anything wrong with my code!
Is there any special input that I am missing?
Thanks/
Saniat
Code: Select all
#include<stdio.h>
#include<string.h>
#define LINE 102
#define SIZE 100
int Ans;
char DecodeMessage[100001];
char Message[LINE][SIZE];
int k = 0;
int testCase;
int stringLength(char str[])
{
int len;
for (len = 0; str[len]; len++);
return len;
}
bool isChar(char ch)
{
if (ch >= 'A' && ch <= 'Z')
return true;
if (ch >= 'a' && ch <= 'z')
return true;
return false;
}
void solve(int lineNo)
{
int i;
int len = stringLength(Message[lineNo]);
int j = 0;
int wordCount = -1;
int n = 0;
for (i = 0; i < len; i++)
{
while(isChar(Message[lineNo][j]))
{
j++;
n++;
}
wordCount++;
if (n > wordCount)
{
n = j - n + wordCount;
DecodeMessage[k] = Message[lineNo][n];
k++;
}
else
wordCount--;
n = 0;
j++;
if (j > len)
break;
}
DecodeMessage[k] = '\0';
DecodeMessage[k++] = '\n';
}
void printCase()
{
if (testCase == 1)
printf("Case #%d:", testCase);
else
printf("\nCase #%d:", testCase);
printf("\n%s",DecodeMessage);
testCase++;
}
void resetArr(char str[])
{
memset(str,0x00,sizeof(str));
}
int main()
{
//freopen("Text.txt", "r", stdin);
//freopen("Text1.txt", "w", stdout);
int T;
scanf("%d", &T);
int i = 0;
k = 0;
testCase = 1;
int const_value = 0;
while (1)
{
gets(Message[i]);
int messageLength = stringLength(Message[i]);
int DecodeLength = stringLength(DecodeMessage);
if (messageLength == 0 && DecodeLength == 0)
{
const_value++;
if (const_value < 10)
{
continue;
}
const_value = 0;
}
if (Message[i][0] == '\0')
{
T--;
int j;
for (j = 0; j < i; j++)
resetArr(Message[j]);
i = 0;
k = 0;
printCase();
int len = stringLength(DecodeMessage);
for (i = 0; i < len; i++)
DecodeMessage[i] = '\0';
if (T == 0)
break;
}
else
{
solve(i);
i++;
}
}
return 0;
}
Thanks/
Saniat
Re[saniatrasel]: 11220 - Decoding the message.
Hello Saniat,
#1# Input Case #
How about handling below case:
Input:
1
1,234 1*23 12345 12345 123 1234 1234 12 123 1234 1234
Output:
Case #1:
1*34
I checked in uDebug and it seems it accepts numerical digits although in the problem description it said "A word is formed by the letters A-Z and a-z and has at most 30 letters."
#2# Boundary #
You are reading one line with gets(Message);
Message is of length 100. So what if the input line is: 12[100 Spaces]2[100 spaces]564
#1# Input Case #
How about handling below case:
Input:
1
1,234 1*23 12345 12345 123 1234 1234 12 123 1234 1234
Output:
Case #1:
1*34
I checked in uDebug and it seems it accepts numerical digits although in the problem description it said "A word is formed by the letters A-Z and a-z and has at most 30 letters."
#2# Boundary #
You are reading one line with gets(Message);
Message is of length 100. So what if the input line is: 12[100 Spaces]2[100 spaces]564