답안 #510175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510175 2022-01-14T18:39:53 Z NeroZein Tetris (COCI17_tetris) C++14
64 / 80
1 ms 284 KB
#include <bits/stdc++.h>
#define endl "\n"
#define sz = s.size()
using ll = long long;
const int Z = 1e8+9;
const int INF = 1e9+9;
const int mod = 1e9+7;
using namespace std;
ll fp (ll x, ll y)
{
    if (y == 0) return 1;
    if (y == 1) return x;
    ll ret = fp(x, y/2) % mod;
    if (y % 2) ret *= x;
    return ret;
}
char a[100][100];
ll x, n, mn, mx, sum, ans, dif, t, k , m ;
ll fig1 , fig2 , fig3 , fig4 , fig5 ;
int main()
{

    ios::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n >> m;
    for (int i = 1 ; i <= n ; i++)
        for (int j = 1 ; j <= m ; j++)
            cin >> a[i][j];

    for (int i = 1 ; i <= n  ; i++){
        for (int j = 1 ; j <= m ; j++){
            if (a[i][j] == '.') continue;
            if (a[i][j] == a[i][j+1] && a[i][j] == a[i+1][j] && a[i][j] == a[i+1][j+1]){
                fig1++;
                a[i][j] = '.' ;
                a[i][j+1] = '.' ;
                a[i+1][j] = '.' ;
                a[i+1][j+1] = '.' ;
            }
            else if (a[i][j] == a[i][j+1] && a[i][j] == a[i][j+2] && a[i][j] == a[i][j+3]){
                    fig2++;
                    a[i][j] = '.';
                    a[i][j+1] = '.';
                    a[i][j+2] = '.';
                    a[i][j+3] = '.';
            }
            else if (a[i][j] == a[i+1][j] && a[i][j] == a[i+2][j] && a[i][j] == a[i+3][j]){
                fig2++;
                a[i][j] = '.';
                a[i+1][j] = '.';
                a[i+2][j] = '.';
                a[i+3][j] = '.';
            }

            else if (a[i][j] == a[i][j+1] && a[i][j] == a[i+1][j] && a[i][j] == a[i+1][j-1]){
                fig3++;
                a[i][j] = '.';
                a[i][j+1] = '.';
                a[i+1][j] = '.';
                a[i+1][j-1] = '.';
            }
            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]){
                fig3++;
                a[i][j] = '.';;
                a[i+1][j] = '.';
                a[i+1][j+1] = '.';
                a[i+2][j+1] = '.';
            }

            else if (a[i][j] == a[i][j+1] && a[i][j] == a[i+1][j+1] && a[i][j] == a[i+1][j+2]){
                fig4++;
                a[i][j] = '.';
                a[i][j+1] = '.';
                a[i+1][j+1] = '.';
                a[i+1][j+2] = '.';
            }
            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]){
                fig4++;
                a[i][j] = '.';;
                a[i+1][j] = '.';
                a[i+1][j-1] = '.';
                a[i+2][j-1] = '.';
            }
            else if (a[i][j] == a[i+1][j] && a[i][j] == a[i+2][j] && (a[i+1][j+1] ==  a[i][j] || a[i+1][j-1] == a[i][j])){
                fig5++;
                a[i][j] = '.' ;
                a[i+1][j] = '.';
                a[i+2][j] = '.';
                if (a[i+1][j-1] == a[i][j]) a[i+1][j-1]++ ;
                else a[i+1][j+1]++ ;
            }
            else if (a[i][j] == a[i][j+1] && a[i][j] == a[i][j+2] && (a[i][j] == a[i-1][j+1] || a[i][j] == a[i+1][j+1])){
                fig5++;
                a[i][j]++ ;
                a[i][j+1]++ ;
                a[i][j+2]++ ;
                if (a[i][j] == a[i-1][j+1]) a[i-1][j+1] = '.';
                else a[i+1][j+1] = '.';
            }
        }
    }
    cout << fig1 << endl << fig2 << endl << fig3 << endl << fig4 << endl << fig5 << endl;

    return 0 ;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 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 0 ms 284 KB Output is correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Incorrect 0 ms 204 KB Output isn't correct