답안 #472723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472723 2021-09-14T08:39:00 Z BidoTeima Tetris (COCI17_tetris) C++17
16 / 80
1 ms 204 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc int tttttt;cin>>tttttt;while(tttttt--)
#define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1])
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int n,m;
vector<vector<char>>grid;
vector<vector<bool>>vis;
bool valid(int x, int y, char c){
    return x>=1&&x<=n&&y>=1&&y<=m&&vis[x][y]==0&&grid[x][y]==c;
}
void dfs(int x, int y){
    if(vis[x][y])
        return;
    vis[x][y]=1;
    for(int i = 0; i < 8; i++){
        if(valid(x+dx[i],y+dy[i],grid[x][y])){
            dfs(x+dx[i],y+dy[i]);
        }
    }
}
int main(){
    ACPLS();
    cin>>n>>m;
    grid=vector<vector<char>>(n+5,vector<char>(m+5));
    vis=vector<vector<bool>>(n+5,vector<bool>(m+5,0));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin>>grid[i][j];
        }
    }
    int ans=0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(!vis[i][j]&&grid[i][j]!='.'){
                dfs(i,j);
                ++ans;
            }
        }
    }
    cout<<ans<<'\n';
    for(int i = 0; i < 4; i++)
        cout<<"0\n";

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Incorrect 0 ms 204 KB Output isn't correct