416 - LED Test

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

Moderator: Board moderators

hhicask
New poster
Posts: 4
Joined: Fri Jun 20, 2014 10:06 pm

Re: 416 - LED Test

Post by hhicask »

Hi.
Somebody can say me why this example is MISMATCH?

Code: Select all

2
YYNNNNY
YYNYNYN
My Output: MATCH

Output Udebug: MISMATCH

I think that the first line could be the number 9(YYYYNYY) and the second line could be the number 8(YYYYYYY)

Thanks in advance and sorry my poor english.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 416 - LED Test

Post by brianfry713 »

No segments will ever fail into the ON mode; no burned out segments will recover.
If YYNNNNY is 9(YYYYNYY) then segments c, d, and f are burned out.
If YYNYNYN is 8(YYYYYYY) it's a MISMATCH because segments d and f are now on.
Check input and AC output for thousands of problems on uDebug!
hhicask
New poster
Posts: 4
Joined: Fri Jun 20, 2014 10:06 pm

Re: 416 - LED Test

Post by hhicask »

: D thanks so much brianfy, now I understood the problem and I got AC :)
b1gm4f14
New poster
Posts: 3
Joined: Fri Apr 11, 2014 9:08 pm

416 - LED Test

Post by b1gm4f14 »

checked my output with Udebug.....
tried all the possible inputs and outputs....
everything is right although UVA is giving WA....
will u plz check my code?

Code: Select all

#include<bits/stdc++.h>
using namespace std;

int led[]={126,48,109,121,51,91,95,112,127,123};
bool chk[10],flag=false;

int main()
{
int Count=0;
//freopen("arf.txt","r",stdin);
int n,data[12];
char ch,temp = 127;
while(1){
memset(data,0,sizeof(data));
flag=false;
scanf("%d",&n);
if(n<1||n>10)
break;
for( int i=1;i<=n;i++)
{
for(int j=6;j>=0;j--)
{
scanf(" %c",&ch);
if(ch=='Y')
data[i] = data[i]|1<<j;
}
// printf("%d\n",data[i]);
}

for (int i=0;i<=9;i++)
{
if((data[1]&led[i])==data[1])
chk[i] = true;
}
for(int i=0;i<=9&&!flag;i++)
{
temp =0;
if(chk[i])
{
chk[i]=false;
for(int j=1;j<=n;j++)
{
//if(data[j]!=0)
temp = temp |(((127&led[i-j+1]))^data[j]);
if((data[j]&led[i-j+1])==data[j]&&!(data[j] & temp))
{
if(j==n)
flag = true;
continue;

}
else break;
}
}

}
if(flag)
printf("MATCH\n");
else
printf("MISMATCH\n");
}
return 0;
}
Last edited by brianfry713 on Fri Jun 19, 2015 6:31 am, edited 1 time in total.
Reason: Added code blocks
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 416 - LED Test

Post by metaphysis »

The test data on uDebug end with end of line instead of 0, beware of it.
Post Reply

Return to “Volume 4 (400-499)”