結果
| 問題 | No.24 数当てゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-18 00:11:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 2,267 bytes |
| コンパイル時間 | 259 ms |
| コンパイル使用メモリ | 31,616 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 05:40:43 |
| 合計ジャッジ時間 | 704 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define READ_BUFSIZE ( 16 )
#define READ_DELIMITER ( " " )
//標準入力取得(1行)
int GetStdin( char* pszStr, int lMaxLen )
{
int lLen = 0;
memset( pszStr, 0, lMaxLen );
if( fgets( pszStr, lMaxLen, stdin ) )
{
lLen = strlen( pszStr );
if( lLen >= 1 )
{
if( pszStr[ lLen - 1 ] == 0x0A )
{
pszStr[ lLen - 1 ] = 0;
lLen--;
}
}
}
return( lLen );
}
//標準入力を取得
//区切り文字で区切られている文字列を取り出す
//取り出した文字列のポインタをポインタ配列にセットする (文字列型)
int split(char *pszStr, int lStrMax, const char *pszDelim, char *apszOutList[]) {
char *pszToken;
int count = 0;
char *pszNext_token = 0;
int lLen = 0;
int lNum = 0;
memset( pszStr, 0, lStrMax );
lLen = GetStdin( pszStr, lStrMax );
if( lLen > 0 )
{
pszToken = strtok( pszStr, pszDelim );
while ( pszToken != NULL )
{
apszOutList[ lNum ] = pszToken;
lNum++;
// pszToken = strtok_s(NULL, pszDelim, &pszNext_token);
pszToken = strtok( NULL, pszDelim );
}
}
return lNum;
}
int main(int argc, char *argv[])
{
char szRead[READ_BUFSIZE] = "";
char* psOutbuf[5] = { 0 };
split( szRead, READ_BUFSIZE, READ_DELIMITER, psOutbuf );
int N = atoi( psOutbuf[0] );
char map['9'+1] = {0};
for( int i = 0; i < N; i++ )
{
split( szRead, READ_BUFSIZE, READ_DELIMITER, psOutbuf );
if( strcmp( psOutbuf[4], "YES" ) == 0 )
{
for( int j = '0'; j <= '9'; j++ )
{
int k = 0;
bool bFlag = false;
for( k = 0; k < 4; k++ )
{
if( j == *psOutbuf[k] )
{
bFlag = true;
break;
}
}
if( bFlag && map[j] != -1 )
map[j] = 1;
else
map[j] = -1;
}
}
else
{
map[ *psOutbuf[0] ] = -1;
map[ *psOutbuf[1] ] = -1;
map[ *psOutbuf[2] ] = -1;
map[ *psOutbuf[3] ] = -1;
}
}
int l = '0';
for( l = '0'; l <= '9'; l++ )
{
if( map[l] == 1 )
{
printf( "%c\n", l );
break;
}
}
if( l > '9' )
{
for( l = '0'; l <= '9'; l++ )
{
if( map[l] == 0 )
{
printf( "%c\n", l );
break;
}
}
}
return 0;
}