답안 #1111246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111246 2024-11-11T20:38:41 Z vjudge1 Tetris (COCI17_tetris) C++17
80 / 80
1 ms 336 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
bool c(ll i,ll j){
    return i>=0 && i<n &&j>=0 && j<m;
}
int main(){
    ll p[5]={};
cin>>n>>m;
char g[n][m];
for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++){
        cin>>g[i][j];
    }
}
for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++){
        if(c(i+1,j+1) &&g[i][j] == g[i][j+1] && g[i][j+1] == g[i+1][j] && g[i+1][j] == g[i+1][j+1] && g[i][j]!='.' ){
            p[0]++;
        }
        if(c(i,j+3) &&g[i][j] == g[i][j+1] && g[i][j+1] == g[i][j+2] && g[i][j+2] == g[i][j+3] && g[i][j]!='.'){
            p[1]++;
        }
        if(c(i+3,j) && g[i][j] == g[i+1][j] && g[i+1][j] == g[i+2][j] && g[i+2][j] == g[i+3][j] && g[i][j]!='.'){
            p[1]++;
        }
        if(c(i-1,j+2) && g[i][j]==g[i][j+1] && g[i][j+1]==g[i-1][j+1] && g[i-1][j+1]==g[i-1][j+2] && g[i][j]!='.'){
            p[2]++;
        }
        if(c(i+2,j+1) && g[i][j]==g[i+1][j] && g[i+1][j]==g[i+1][j+1] && g[i+1][j+1]==g[i+2][j+1] && g[i][j]!='.'){
            p[2]++;
        }
        if(c(i+1,j+2) && g[i][j]==g[i][j+1] && g[i][j+1] == g[i+1][j+1] && g[i+1][j+1] == g[i+1][j+2] && g[i][j]!='.'){
            p[3]++;
        }
        if(c(i+2,j-1) && g[i][j]==g[i+1][j] && g[i+1][j] == g[i+1][j-1] && g[i+1][j-1]== g[i+2][j-1] && g[i][j]!='.'){
            p[3]++;
        }
        if(c(i-1,j+2) && g[i][j]==g[i][j+1] && g[i][j+1]==g[i][j+2] && g[i][j]==g[i-1][j+1] && g[i][j]!='.'){
            p[4]++;
        }
        if(c(i+1,j+2) && g[i][j]==g[i][j+1] && g[i][j+1]==g[i][j+2] && g[i][j]==g[i+1][j+1] && g[i][j]!='.'){
            p[4]++;
        }
        if(c(i+2,j+1) && g[i][j]==g[i+1][j] && g[i+1][j]==g[i+2][j] && g[i][j]==g[i+1][j+1] && g[i][j]!='.'){
            p[4]++;
        }
        if(c(i+2,j-1) && g[i][j]==g[i+1][j] && g[i+1][j]==g[i+2][j] && g[i][j]==g[i+1][j-1] && g[i][j]!='.'){
            p[4]++;
        }
    }
}
    for(ll i:p){
        cout<<i<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct