답안 #472810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472810 2021-09-14T11:10:39 Z Ahmed57 Tetris (COCI17_tetris) C++14
80 / 80
1 ms 204 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    char a[n+10][m+10];memset(a,'.',sizeof a);
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    map<int,int> mp;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++)
    {
      if(a[i][j]!='.'){
      if(a[i][j]==a[i+1][j+1]&&a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j]){
          mp[1]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i][j+2]&&a[i][j]==a[i][j+3]){
          mp[2]++;
      }
      if(a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+3][j]){
          mp[2]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i-1][j+1]&&a[i][j]==a[i-1][j+2]){
          mp[3]++;
      }
      else if(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+2][j+1]){
          mp[3]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i+1][j+2]){
          mp[4]++;
      }
      if(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j-1]&&a[i][j]==a[i+2][j-1]){
          mp[4]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i-1][j+1]&&a[i][j]==a[i][j+2]){
          mp[5]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i-1][j+1]&&a[i][j]==a[i+1][j+1]){
          mp[5]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j+1]&&a[i][j]==a[i][j+2]){
          mp[5]++;
      }
      if(a[i][j]==a[i][j+1]&&a[i][j]==a[i-1][j]&&a[i][j]==a[i+1][j]){
          mp[5]++;
      }
      }
    }
}
    for(int i = 1;i<=5;i++){
        cout<<mp[i]<<"\n";
    }
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct