結果
| 問題 | No.11 カードマッチ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-04-19 23:42:53 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,417 bytes | 
| コンパイル時間 | 322 ms | 
| コンパイル使用メモリ | 32,000 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 09:32:02 | 
| 合計ジャッジ時間 | 1,039 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 13 WA * 6 | 
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define READ_BUFSIZE ( 32 )
#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, int *palOutList) {
    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 ) 
	    {
            *palOutList = atoi( pszToken );
			lNum++;
//	        pszToken = strtok_s(NULL, pszDelim, &pszNext_token);
		    pszToken = strtok( NULL, pszDelim );
			palOutList++;
	    }
	}
    return lNum;
}
struct stCount
{
	int type;
	int count;
};
void count( stCount *pCount, int I )
{
	for( int i = 0; i < 100; i++ )
	{
		if( pCount[i].type == I || pCount[i].type == 0 )
		{
			pCount[i].count++;
			if( pCount[i].type == 0 )
				pCount[i].type = I;
			break;
		}
	}
}
int main(int argc, char *argv[]) 
{
	char szRead[READ_BUFSIZE] = "";
	int OutList[2] = { 0 };
	split( szRead, READ_BUFSIZE, READ_DELIMITER, OutList );
	int W = OutList[0]; //種類
	split( szRead, READ_BUFSIZE, READ_DELIMITER, OutList );
	int H = OutList[0]; //数字
	
	split( szRead, READ_BUFSIZE, READ_DELIMITER, OutList );
	int N = OutList[0]; //手札の数
	stCount WCount[100];
	stCount HCount[100];
	memset( WCount, 0, sizeof( stCount )*100 );
	memset( HCount, 0, sizeof( stCount )*100 );
	for( int i = 0; i < N; i++ )
	{
		split( szRead, READ_BUFSIZE, READ_DELIMITER, OutList );
		count( WCount, OutList[0] );
		count( HCount, OutList[1] );
	}
	int Num = 0;
	int j = 0;
	for( j = 0; WCount[j].count; j++ )
	{
			Num += H - WCount[j].count;
	}
	for( int k = 0; HCount[k].count; k++ )
	{
			Num += W - HCount[k].count - (j-HCount[k].count) ;
	}
	printf( "%d\n", Num );
	return 0;
}
            
            
            
        