# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
736509 | vjudge1 | Emacs (COCI20_emacs) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define N 107
#define big 1000000000000000007
int n,m;
char arr[N][N];
int var[N][N];
void bfs(int xx,int yy){
queue<pair<int,int>> q;
q.push({xx,yy});
while(q.size()){
int i=q.front().first, j=q.front().second;
q.pop();
if(var[i][j] || arr[i][j]=='.')continue;
var[i][j]=1;
if(i!=0) q.push({i-1,j});
if(i!=n-1) q.push({i+1,j});
if(j!=0)q.push({i,j-1});
if(j!=m-1)q.push({i,j+1});
}
}
int main(){
lalala;
cin>>n>>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)cin>>arr[i][j];
}
int cev=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(var[i][j]|| arr[i][j]=='.')continue;
cev++;
bfs(i,j);
}
}
cout<<cev<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |