# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234423 | VEGAnn | Tetris (COCI17_tetris) | C++14 | 5 ms | 512 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 all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define a2 array<int,2>
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 110;
const int oo = 2e9;
char c[N][N];
vector<a2> vc, pat[11];
int n, m, gx, gy, ans[5];
char gc;
void rec(int x, int y){
if (c[x][y] == '.' || c[x][y] != gc) return;
c[x][y] = '.';
vc.PB({x - gx, y - gy});
if (x > 0) rec(x - 1, y);
if (y > 0) rec(x, y - 1);
if (y < m - 1) rec(x, y + 1);
if (x < n - 1) rec(x + 1, y);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> c[i][j];
pat[0] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}};
pat[1] = {{0, 0}, {0, 1}, {0, 2}, {0, 3}};
pat[2] = {{0, 0}, {1, 0}, {2, 0}, {3, 0}};
pat[3] = {{0, 0}, {0, 1}, {1, -1}, {1, 0}};
pat[4] = {{0, 0}, {1, 0}, {1, 1}, {2, 1}};
pat[5] = {{0, 0}, {0, 1}, {1, 1}, {1, 2}};
pat[6] = {{0, 0}, {1, -1}, {1, 0}, {2, -1}};
pat[7] = {{0, 0}, {1, -1}, {1, 0}, {1, 1}};
pat[8] = {{0, 0}, {1, 0}, {1, 1}, {2, 0}};
pat[9] = {{0, 0}, {1, -1}, {1, 0}, {2, 0}};
pat[9] = {{0, 0}, {0, 1}, {0, 2}, {1, 1}};
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++){
vc.clear();
gx = i; gy = j;
gc = c[i][j];
if (c[i][j] == '.') continue;
rec(i, j);
sort(all(vc));
for (int j = 0; j < 11; j++)
if (vc == pat[j]){
if (j < 1) ans[0]++; else
if (j < 3) ans[1]++; else
if (j < 5) ans[2]++; else
if (j < 7) ans[3]++; else ans[4]++;
}
}
for (int i = 0; i < 5; i++)
cout << ans[i] << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |