結果
問題 |
No.697 池の数はいくつか
|
ユーザー |
![]() |
提出日時 | 2018-10-18 17:18:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 725 bytes |
コンパイル時間 | 471 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 440,772 KB |
最終ジャッジ日時 | 2024-11-25 14:24:15 |
合計ジャッジ時間 | 9,802 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 MLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:21: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘bool*’ [-Wformat=] 26 | scanf("%d", &f[i][j]); | ~^ ~~~~~~~~ | | | | | bool* | int* main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%d %d", &h, &w); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:26:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d", &f[i][j]); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> bool f[3001][3001]; bool c[3001][3001]; int ans=0; int h,w; void check(short i,short j,bool aa){ if ((i<0)||(i>=h)) return; if ((j<0)||(j>=w)) return; if (c[i][j]) return; else if (!f[i][j]) return; else if (aa) { ++ans; } c[i][j]=true; check(i-1,j,false); check(i+1,j,false); check(i,j-1,false); check(i,j+1,false); } int main() { scanf("%d %d", &h, &w); for (short i=0;i<h;i++) { for (short j=0;j<w;j++) { scanf("%d", &f[i][j]); c[i][j]=false; } } for (short i=0;i<h;i++) { for (short j=0;j<w;j++) { check(i,j,true); } } printf("%d\n",ans); return 0; }