# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
510175 | NeroZein | Tetris (COCI17_tetris) | C++14 | 1 ms | 284 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 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] = '.';
a[i][j+1] = '.';
a[i][j+2] = '.';
a[i][j+3] = '.';
}
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] = '.';
a[i+1][j] = '.';
a[i+2][j] = '.';
a[i+3][j] = '.';
}
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+1][j] = '.';
a[i+1][j+1] = '.';
a[i+2][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+1] = '.';
a[i+1][j+2] = '.';
}
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+1][j] = '.';
a[i+1][j-1] = '.';
a[i+2][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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |