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