bzzz... I'm bored out of my scull trying to get this one accepted.
I'll just ask for the start, whether there is anything in the description stated not clearly enough?
And one more thing: does rejected record count as the 'first record of of the corresponding Style Code group'?
I appreciate any help available,
Ivor
277 - Cabinets
Moderator: Board moderators
hmm... I don't think it got any clearer.
Say I memorize the first name of the stylegroup. If it's empty -- I reject it. If I find another record with the same style code and no name, I look at the memorized name. Again -- if it's empty I reject it. Right? If not, then what's the problem?
// puzzled
Ivor

Say I memorize the first name of the stylegroup. If it's empty -- I reject it. If I find another record with the same style code and no name, I look at the memorized name. Again -- if it's empty I reject it. Right? If not, then what's the problem?
What did you mean? Did you mean that I should use the name of the first record that has a name? (and of course the same style code)i found that the name will be differed from the first record, but just use whatever name when there's one provided.
// puzzled
Ivor
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
277 : Cabinets
Hi,
I've got WA on this problem. I got a H-U-G-E data set from my friend and my program matches exactly with the correct output of that data set. I'm really confused with this problem. Someone please help me..
Thanks in advance,
I've got WA on this problem. I got a H-U-G-E data set from my friend and my program matches exactly with the correct output of that data set. I'm really confused with this problem. Someone please help me..

Thanks in advance,
Code: Select all
#include<stdio.h>
#include<string.h>
#define MAX 200000
struct s{
char code[5], name[20], desc[20], ext[30], price[10];
} cab[MAX];
int n;
int main(){
//freopen("In.txt", "r", stdin);
//freopen("Out.txt", "w", stdout);
int i, j, t, len, price;
char st[70], itemId[25], itemDesc[45];
bool f = 1;
gets(st);
sscanf(st, "%d", &t);
gets(st);
while(t--){
if(f) f= 0;
else putchar(0xA);
n = 0;
while(gets(st) && st[0]){
len = strlen(st);
for(i=0; st[i]!=','; ++i) cab[n].code[i] = st[i]; cab[n].code[i] = 0;
for(++i,j=0; st[i]!=','; ++i,++j) cab[n].name[j] = st[i]; cab[n].name[j] = 0;
for(++i,j=0; i < len && st[i]!=','; ++i,++j) cab[n].desc[j] = st[i]; cab[n].desc[j] = 0;
for(++i,j=0; i < len && st[i]!=','; ++i,++j) cab[n].ext[j] = st[i]; cab[n].ext[j] = 0;
for(++i,j=0; i < len && st[i]!=','; ++i,++j) cab[n].price[j] = st[i]; cab[n++].price[j] = 0;
}
printf("Item Id,Item Desc,Item Price\n");
for(i=0; i<n; ++i){
sprintf(itemId, "%03s", cab[i].code);
strcat(itemId, cab[i].desc);
if(strlen(itemId) > 13) continue;
if(!cab[i].name[0]){
for(j=0; j<i && strcmp(cab[j].code, cab[i].code); ++j);
if(j == i || !cab[j].name[0]) continue;
strcpy(itemDesc, cab[j].name);
}
else strcpy(itemDesc, cab[i].name);
if(cab[i].ext[0]){
strcat(itemDesc, "-");
strcat(itemDesc, cab[i].ext);
}
if(strlen(itemDesc) > 30) itemDesc[30] = 0;
if(!cab[i].price[0]) price = 0;
else sscanf(cab[i].price, "%d", &price);
printf("%s,%s,%01d.%02d\n", itemId,itemDesc,price/100,price%100);
}
}
return 0;
}