# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
510053 |
2022-01-14T15:41:07 Z |
Jean7 |
Tetris (COCI17_tetris) |
C++14 |
|
1 ms |
316 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 ;
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] ) )
{
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 ;
}
Compilation message
tetris.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main ()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
288 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 |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |