Submission #510168

#TimeUsernameProblemLanguageResultExecution timeMemory
510168NeroZeinTetris (COCI17_tetris)C++14
40 / 80
1 ms204 KiB
#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] = 1; a[i][j+1] = 1; a[i][j+2] = 1; a[i][j+3] = 1; } 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] = 1; a[i+1][j] = 1; a[i+2][j] = 1; a[i+3][j] = 1; } 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][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+1][j+1] && a[i][j] == a[i+1][j+2]){ fig4++; 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]){ fig4++; 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+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 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...