답안 #884316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884316 2023-12-07T06:43:16 Z vjudge1 Tetris (COCI17_tetris) C++17
80 / 80
1 ms 408 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    const int lim=2e5+100;
#else
    const int lim=2e3+100;
#endif

#include "bits/stdc++.h"
using namespace std;

#define int int64_t
#define pb push_back

const int mod=1e9+7;
using pii=pair<int,int>;

inline void solve(){
    int n,m;
    cin>>n>>m;
    string g[n];
    for(int i=0;i<n;i++){
        cin>>g[i];
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<m-1;j++){
            if(g[i][j]=='.')continue;
            if(g[i][j]==g[i][j+1]&&
            g[i][j]==g[i+1][j]&&
            g[i][j]==g[i+1][j+1]){
                ans++;
            }
        }
    }
    cout<<ans<<"\n";
    ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m-3;j++){
            if(g[i][j]=='.')continue;
            if(g[i][j]==g[i][j+1]&&
            g[i][j]==g[i][j+2]&&
            g[i][j]==g[i][j+3]){
                ans++;
            }
        }
    }
    for(int i=0;i<n-3;i++){
        for(int j=0;j<m;j++){
            if(g[i][j]=='.')continue;
            if(g[i][j]==g[i+1][j]&&
            g[i][j]==g[i+2][j]&&
            g[i][j]==g[i+3][j]){
                ans++;
            }
        }
    }
    cout<<ans<<"\n";
    int ans1=0,ans2=0;
    for(int i=0;i<n-1;i++){
        for(int j=1;j<m-1;j++){
            if(g[i][j]=='.')continue;
            if(g[i][j]==g[i+1][j]){
                if(g[i][j]==g[i][j+1]&&
                g[i][j]==g[i+1][j-1]){
                    ans1++;
                }
                if(g[i][j]==g[i][j-1]&&
                g[i][j]==g[i+1][j+1]){
                    ans2++;
                }
            }
        }
    }
    for(int i=1;i<n-1;i++){
        for(int j=0;j<m-1;j++){
            if(g[i][j]=='.')continue;
            if(g[i][j]==g[i][j+1]){
                if(g[i][j]==g[i-1][j]&&
                g[i][j]==g[i+1][j+1]){
                    ans1++;
                }
                if(g[i][j]==g[i+1][j]&&
                g[i][j]==g[i-1][j+1]){
                    ans2++;
                }
            }
        }
    }
    cout<<ans1<<"\n"<<ans2<<"\n";
    ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(g[i][j]=='.')continue;
            int count=
            (i+1<n&&g[i][j]==g[i+1][j])+
            (j+1<m&&g[i][j]==g[i][j+1])+
            (i&&g[i][j]==g[i-1][j])+
            (j&&g[i][j]==g[i][j-1]);
            if(count==3){
                ans++;
            }
        }
    }
    cout<<ans<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
#else
    //freopen("grass.in","r",stdin);
    //freopen("grass.out","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 408 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct