# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
510082 | Jean7 | Tetris (COCI17_tetris) | C++14 | 1 ms | 312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |