結果

問題 No.2393 Bit Grid Connected Component
ユーザー Lisp_CoderLisp_Coder
提出日時 2023-07-28 23:06:02
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,583 bytes
コンパイル時間 1,332 ms
コンパイル使用メモリ 34,244 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-16 07:02:40
合計ジャッジ時間 6,080 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<assert.h>
#include<complex.h>
#include<ctype.h>
#include<errno.h>
#include<fenv.h>
#include<float.h>
#include<inttypes.h>
#include<iso646.h>
#include<limits.h>
#include<locale.h>
#include<math.h>
#include<setjmp.h>
#include<signal.h>
#include<stdalign.h>
#include<stdarg.h>
#include<stdatomic.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<stdio.h>
#include<stdlib.h>
#include<stdnoreturn.h>
#include<string.h>
#include<tgmath.h>
#include<time.h>
#include<wchar.h>
#include<wctype.h>

void dfs(int x, int y, int grid[260][60], int visited[260][60]) {
    if (x < 0 || y < 0 || x >= 260 || y >= 60 || visited[x][y] || !grid[x][y]) {
        return;
    }
    visited[x][y] = 1;
    dfs(x - 1, y, grid, visited);
    dfs(x + 1, y, grid, visited);
    dfs(x, y - 1, grid, visited);
    dfs(x, y + 1, grid, visited);
}

int main() {
    int T;
    scanf("%d", &T);
    for (int i = 0; i < T; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        int grid[260][60] = {0};
        int visited[260][60] = {0};
        for (int row = 0; row < 260; row++) {
            for (int col = 0; col < 60; col++) {
                if (row & (1ULL << col)) {
                    grid[row][col] = 1;
                }
            }
        }
        int count = 0;
        dfs(x, y, grid, visited);
        for (int row = 0; row < 260; row++) {
            for (int col = 0; col < 60; col++) {
                if (visited[row][col]) {
                    count++;
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}
0