結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
matsukin1111
|
| 提出日時 | 2019-04-30 11:03:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,406 bytes |
| コンパイル時間 | 1,087 ms |
| コンパイル使用メモリ | 98,444 KB |
| 実行使用メモリ | 751,232 KB |
| 最終ジャッジ日時 | 2024-11-25 14:47:06 |
| 合計ジャッジ時間 | 9,586 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 2 |
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
vector<vector<char>>mp(3030,vector<char>(3030));
int used[3030][3030];
int h, w;
void dfs(int x,int y) {
if (used[y][x] != 0)return;
used[y][x] = 1;
int dx[4] = {-1,0,1,0};
int dy[4] = { 0,-1,0,1 };
rep(i, 0, 4) {
int _x = x + dx[i];
int _y = y + dy[i];
if (0 <= _x && _x <= w - 1 && 0 <= _y && _y <= h - 1) {
if (used[_y][_x] == 0 && mp[_y][_x] == '1') {
dfs(_x, _y);
}
}
}
return;
}
int main() {
cin >> h >> w;
rep(i, 0, h)rep(j,0,w)cin >> mp[i][j];
int ans = 0;
rep(i, 0, h)rep(j,0,w){
if (mp[i][j] == '1' && used[i][j] == 0) {
dfs(j,i);
ans++;
}
}
cout << ans << endl;
return 0;
}
matsukin1111