結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
greentea011
|
| 提出日時 | 2018-10-18 17:06:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 713 bytes |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 22,784 KB |
| 実行使用メモリ | 300,336 KB |
| 最終ジャッジ日時 | 2024-11-25 14:24:47 |
| 合計ジャッジ時間 | 8,579 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 MLE * 1 |
コンパイルメッセージ
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(int i,int 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 (int i=0;i<h;i++) {
for (int j=0;j<w;j++) {
scanf("%d", &f[i][j]);
c[i][j]=false;
}
}
for (int i=0;i<h;i++) {
for (int j=0;j<w;j++) {
check(i,j,true);
}
}
printf("%d\n",ans);
return 0;
}
greentea011