Submission #510082

# Submission time Handle Problem Language Result Execution time Memory
510082 2022-01-14T16:43:09 Z Jean7 Tetris (COCI17_tetris) C++14
80 / 80
1 ms 312 KB
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long

using namespace std ;

int32_t main ()
{
    fastio
    int n , m ;
    cin >> n >> m ;
    char a[n+2][m+2] ;
    for ( int i = 0 ; i < n+2 ; i++ ) a[i][0] = '.' ;
    for ( int k = 0 ; k < m+2 ; k++ ) a[0][k] = '.' ;
    for ( int i = 0 ; i < n+2 ; i++ ) a[i][m+1] = '.' ;
    for ( int k = 0 ; k < m+2 ; k++ ) a[n+1][k] = '.' ;
    for ( int i = 1 ; i < n+1 ; i++ ) for ( int k = 1 ; k < m+1 ; k++ ) cin >> a[i][k] ;
    int one = 0 , two = 0 , three = 0 , four = 0 , five = 0 ;
    for ( int i = 0 ; i < n+2 ; i++ )
    {
        for ( int k = 0 ; k < m+2 ; k++ )
        {
            if ( a[i][k] != '.' )
            {
                if ( a[i][k+1] == a[i][k] && a[i][k+2] == a[i][k] && a[i][k+3] == a[i][k] )
                {
                    two++ ;
                    a[i][k] = '.' ; a[i][k+1] = '.' ; a[i][k+2] = '.' ; a[i][k+3] = '.' ;
                }
                else if ( a[i+1][k] == a[i][k] && a[i+2][k] == a[i][k] && a[i+3][k] == a[i][k] )
                {
                    two++ ;
                    a[i][k] = '.' ; a[i+1][k] = '.' ; a[i+2][k] = '.' ; a[i+3][k] = '.' ;
                }
                else if ( a[i][k+1] == a[i][k] && a[i+1][k] == a[i][k] && a[i+1][k+1] == a[i][k] )
                {
                    one++ ;
                    a[i][k] = '.' ; a[i+1][k] = '.' ; a[i][k+1] = '.' ; a[i+1][k+1] = '.' ;
                }
                else if ( a[i][k+1] == a[i][k] && a[i+1][k] == a[i][k] && a[i+1][k-1] == a[i][k] )
                {
                    three++ ;
                    a[i][k] = '.' ; a[i][k+1] = '.' ; a[i+1][k] = '.' ; a[i+1][k-1] = '.' ;
                }
                else if ( a[i+1][k] == a[i][k] && a[i+1][k+1] == a[i][k] && a[i+2][k+1] == a[i][k] )
                {
                    three++ ;
                    a[i][k] = '.' ; a[i+1][k] = '.' ; a[i+1][k+1] = '.' ; a[i+2][k+1] = '.' ;
                }
                else if ( a[i][k+1] == a[i][k] && a[i+1][k+1] == a[i][k] && a[i+1][k+2] == a[i][k] )
                {
                    four++ ;
                    a[i][k] = '.' ; a[i][k+1] = '.' ; a[i+1][k+1] = '.' ; a[i+1][k+2] = '.' ;
                }
                else if ( a[i+1][k] == a[i][k] && a[i+1][k-1] == a[i][k] && a[i+2][k-1] == a[i][k] )
                {
                    four++ ;
                    a[i][k] = '.' ; a[i+1][k] = '.' ; a[i+1][k-1] = '.' ; a[i+2][k-1] = '.' ;
                }
                else if ( a[i][k+1] == a[i][k] && a[i][k+2] == a[i][k] && ( a[i+1][k+1] == a[i][k] || a[i-1][k+1] == a[i][k] ) )
                {
                    five++ ;
                    if ( a[i+1][k+1] == a[i][k] ) a[i+1][k+1] = '.' ;
                    else if ( a[i-1][k+1] == a[i][k] ) a[i-1][k+1] = '.' ;
                    a[i][k] = '.' ; a[i][k+1] = '.' ; a[i][k+2] = '.' ;
                }
                else if ( a[i+1][k] == a[i][k] && a[i+2][k] == a[i][k] && ( a[i+1][k+1] == a[i][k] || a[i+1][k-1] == a[i][k] ) )
                {
                    five++ ;
                    if ( a[i+1][k+1] == a[i][k] ) a[i+1][k+1] = '.' ;
                    else if ( a[i+1][k-1] == a[i][k] ) a[i+1][k-1] = '.' ;
                    a[i][k] = '.' ; a[i+1][k] = '.' ; a[i+2][k] = '.' ;
                }
            }
        }
    }
    cout << one << "\n" << two << "\n" << three << "\n" << four << "\n" << five << "\n" ;
	return 0 ;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct