Submission #138088

#TimeUsernameProblemLanguageResultExecution timeMemory
138088Linca_RobertTetris (COCI17_tetris)C++14
80 / 80
2 ms504 KiB
#include<bits/stdc++.h> using namespace std; int N, M, cnt[6], nr; int f[20][20]; char a[20][20]; int x_mn, x_mx, y_mn, y_mx; void fill( int x, int y ){ f[x][y] = nr; x_mn = min( x_mn, x ); x_mx = max( x_mx, x ); y_mn = min( y_mn, y ); y_mx = max( y_mx, y ); if( f[x + 1][y] < 0 && a[x + 1][y] == a[x][y] ) fill( x + 1, y ); if( f[x - 1][y] < 0 && a[x - 1][y] == a[x][y] ) fill( x - 1, y ); if( f[x][y + 1] < 0 && a[x][y + 1] == a[x][y] ) fill( x, y + 1 ); if( f[x][y - 1] < 0 && a[x][y - 1] == a[x][y] ) fill( x, y - 1 ); } inline void solve( int i, int j ){ nr++; x_mn = N + 1, x_mx = 0; y_mn = M + 1, y_mx = 0; fill( i, j ); int L = x_mx - x_mn + 1; int C = y_mx - y_mn + 1; if( L == 2 && C == 2 ){ cnt[1]++; return; } if( (L == 1 && C == 4) || (L == 4 && C == 1) ){ cnt[2]++; return; } if( L == 2 && C == 3 ){ if( f[x_mx][y_mn] == f[x_mn][y_mx] ){ cnt[3]++; return; } if( f[x_mn][y_mn] == f[x_mx][y_mx] ){ cnt[4]++; return; } cnt[5]++; return; } if( L == 3 && C == 2 ){ if( f[x_mn][y_mn] == f[x_mx][y_mx] ){ cnt[3]++; return; } if( f[x_mn][y_mx] == f[x_mx][y_mn] ){ cnt[4]++; return; } cnt[5]++; return; } } int main(){ 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++ ) f[i][j] = --nr; nr = 0; for( int i = 1; i <= N; i++ ){ for( int j = 1; j <= M; j++ ){ if( a[i][j] != '.' && f[i][j] < 0 ) solve( i, j ); } } for( int i = 1; i <= 5; i++ ) cout << cnt[i] << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...