1062 - Containers

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

Moderator: Board moderators

Post Reply
User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

1062 - Containers

Post by uDebug » Tue Jan 28, 2014 2:28 pm

Here's some input / output that I found useful during testing / debugging.

Note that the first and third (modified) test cases are courtesy:
http://saicheems.wordpress.com/2013/08/ ... ontainers/

I shortened them so I could work this out by hand.

Input:

Code: Select all

AAQGHIAEIZ
KHJIGEFDDDDDABAA
ANKLAGRABZBQZ
LMNBXVB
end
AC Output:

Code: Select all

Case 1: 5
Case 2: 2
Case 3: 5
Case 4: 4
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

BlackBeard
New poster
Posts: 18
Joined: Wed Dec 17, 2014 9:44 pm

Re: 1062 - Containers

Post by BlackBeard » Thu Dec 18, 2014 10:17 pm

My code gives right output for every input I try. even the critical ones from udebug...
Please help...

Code: Select all

GOT AC
Last edited by BlackBeard on Fri Dec 19, 2014 6:54 pm, edited 1 time in total.

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

Re: 1062 - Containers

Post by brianfry713 » Fri Dec 19, 2014 3:50 am

Don't read from a file.
Check input and AC output for thousands of problems on uDebug!

messiNayan
New poster
Posts: 7
Joined: Thu Feb 20, 2014 7:07 pm

Re: 1062 - Containers

Post by messiNayan » Wed Dec 28, 2016 10:52 am

#define _CRT_SECURE_NO_WARNINGS


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

void initialize(bool *flag)
{
int i;
for (i = 0; i < 26; i++)
flag = false;

return;
}


int main(void)
{
int i, store, n_stack;

bool flag[26];
char input[1001];

int test_case;


test_case = 1;

while (1)
{
memset(input, 0, sizeof(input));
scanf("%s", input);

if (!strcmp(input, "end"))
break;

initialize(flag);

i = strlen(input) - 1;


store = input;

n_stack = 1;

i--;
while (i >= 0)
{
if (input >= store)
store = input;
else
{
if (input >= input[i + 2])
{
if (!flag[store - 65])
{
flag[store - 65] = true;
n_stack++;

}
store = input;

}
else
{
if (!flag[input - 65])
{
flag[input - 65] = true;
n_stack++;

}

}
}

i--;

}

printf("Case %d: %d\n", test_case, n_stack);
test_case++;



}

return 0;
}

Getting wrong answer. It also does not satisfy sample cases in udebug. I think I cannot understand requirement. please help where I am wrong.

Post Reply

Return to “Volume 10 (1000-1099)”