소ê°� ¶
2005/02/28 Accepted 0:00.189 440
단순히 ì¡°ê±´ì—� 나와있는ë�°ë¡œ Decodablility를 파악해 주면 ë�˜ëŠ” ë¬¸ì œë‹¤. 코드를 계ì†� ì••ì¶•í•´ 나가다 보니 수행시간ì�´ 갈수ë¡� 빨ë�¼ì¡Œê³ , ìƒ�위ì—� ëží�¬ë� 수 있었다.
단순히 ì¡°ê±´ì—� 나와있는ë�°ë¡œ Decodablility를 파악해 주면 ë�˜ëŠ” ë¬¸ì œë‹¤. 코드를 계ì†� ì••ì¶•í•´ 나가다 보니 수행시간ì�´ 갈수ë¡� 빨ë�¼ì¡Œê³ , ìƒ�위ì—� ëží�¬ë� 수 있었다.
코드 ¶
~cpp
// no644 - Immediate Decodability
#include <iostream>
#include <cstring>
using namespace std;
const int MAX = 10;
int main()
{
char code[MAX][11];
int i, j, k;
int count = 1;
int nCode, len;
bool isDecodable;
while (cin.peek() != EOF)
{
for (i=0; i<MAX; i++)
{
cin.getline(code[i], 11, '\n');
if (code[i][0] == '9')
break;
}
nCode = i;
for (i=0; i<nCode; i++)
{
for (j=0; j<nCode; j++)
{
if (i==j)
continue;
isDecodable = false;
len = strlen(code[i]);
for (k=0; k<len; k++)
{
if (code[i][k] != code[j][k])
{
isDecodable = true;
break;
}
}
if (isDecodable == false)
break;
}
if (isDecodable == false)
break;
}
cout << "Set " << count++;
if (!isDecodable)
cout << " is not immediately decodable\n";
else
cout << " is immediately decodable\n";
}
return 0;
}










