結果

問題 No.1822 Keima of Shogi
ユーザー mannshi222jpmannshi222jp
提出日時 2022-01-28 21:43:56
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 1,450 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 29,248 KB
実行使用メモリ 374,500 KB
最終ジャッジ日時 2023-08-28 19:34:54
合計ジャッジ時間 3,953 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 RE -
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 6 ms
6,692 KB
testcase_08 AC 6 ms
8,316 KB
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int cnt = 0;

int setnext( int **, int, int, int );

int main()
{
        int N;
        scanf( "%d\n", &N );

        int **masu;

        masu = ( int **) malloc( sizeof(int *)* N );
        for( int i = 0; i < N; i++ ) {
                masu[i] = ( int *) malloc( sizeof(int *)* N );
        }

        for( int i = 0; i < N; i ++ ) {
                for( int j = 0; j < N; j++ ) {
                        masu[i][j] = 0;
                }
        }

        int i,j;
        i = N -1;
        j = (N -1 )/2;
        masu[i][j] = 1;
        cnt++;
        setnext( masu, N, i, j );

        printf("%d\n", cnt );

        return 0;
}


int setnext( int **masu, int N, int i, int j ) {
        int nexti, nextj;
        nexti = i-2;
        nextj = j-1;

        if( nexti < N && nexti >=0 &&
                nextj < N && nextj >=0 ) {
                if( masu[nexti][nextj] == 0 ) {
                        masu[nexti][nextj] = 1;
                        cnt++;
                        setnext( masu, N, nexti, nextj );

                }
        }


        nexti = i-2;
        nextj = j+1;
        if( nexti < N && nexti >=0 &&
                nextj < N && nextj >=0 ) {
                if( masu[nexti][nextj] == 0 ) {
                        masu[nexti][nextj] = 1;
                        cnt++;
                        setnext( masu, N, nexti, nextj );
                }
        }

        return 0;
}
0