I'm starting to become hopeless.
![:-?](./images/smilies/icon_confused.gif)
I've solved it, resolved, revised, found some bugs but still can't get it accepted.
Any help is appreciated,
Ivor
Moderator: Board moderators
Code: Select all
=================
9
=================
null null
=================
8 8
=================
6 5 4
=================
null null null
=================
null null null
=================
8 1 null null
=================
null null null
Code: Select all
4
YYYYYNN
YYYNNNN
YNYYYNN
YNYYNNN
5
YYYYYYY
NNNNNNN
NNNNNNN
NNNNNNN
NNNNNNN
1
YYYYYYY
1
NNNNNNN
4
YYYYYNN
YYYNNNN
YYYYYNN
YNYYNNN
2
YYYYYYY
NNNNYYY
2
YYYNNNN
YYYNNNN
2
YNNYNNY
YNNYNNY
10
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
10
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNYNNNN
NNNNNNN
NNYNNNN
NNYNNNN
Code: Select all
MATCH
MATCH
MATCH
MATCH
MISMATCH
MISMATCH
MATCH
MATCH
MISMATCH
MATCH
Code: Select all
#include<iostream>
using namespace std;
void check_and_store(char str[], int pos, int possible_no[]);
void main()
{
int possible_no[10];
int n;
char tmp[8];
int i, j;
bool match;
cin>>n;
cin.getline(tmp, 8);
while(n)
{
if(n==1)
{
cin.getline(tmp, 8);
cout<<"MATCH\n";
}
else
{
for(i=0;i<n;i++)
{
cin.getline(tmp, 8);
check_and_store(tmp, i, possible_no);
}
i=11-n;
while(1)
{
match=1;
i--;
while(!(possible_no[n-1] & 1<<i) && i>=0)
i--;
if(i==-1)
{
match=0;
break;
}
for(j=0;j<n-1;j++)
{
if((possible_no[n-2-j] & 1<<(i+j+1)) != 1<<(i+j+1))
match=0;
}
if(match)
break;
}
if(match)
cout<<"MATCH\n";
else
cout<<"MISMATCH\n";
}
cin>>n;
cin.getline(tmp, 8);
}
}
void check_and_store(char str[], int pos, int possible_no[])
{
//check 0~9:
possible_no[pos]=1023;
if(str[0]=='Y')
possible_no[pos] &= ~(1<<1) & ~(1<<4);
if(str[1]=='Y')
possible_no[pos] &= ~(1<<5) & ~(1<<6);
if(str[2]=='Y')
possible_no[pos] &= ~(1<<2);
if(str[3]=='Y')
possible_no[pos] &= ~(1<<1) & ~(1<<4) & ~(1<<7);
if(str[4]=='Y')
possible_no[pos] &= ~(1<<1) & ~(1<<3) & ~(1<<4) & ~(1<<5) & ~(1<<7) & ~(1<<9);
if(str[5]=='Y')
possible_no[pos] &= ~(1<<1) & ~(1<<2) & ~(1<<3) & ~(1<<7);
if(str[6]=='Y')
possible_no[pos] &= ~(1<<0) & ~(1<<1) & ~(1<<7);
}