# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44280 | JustInCase | Tetris (COCI17_tetris) | C++17 | 2 ms | 868 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>
using namespace std;
//------------------------------------------------
struct Figure {
int type;
vector< int > xChanges, yChanges;
Figure();
Figure(int type, const vector< int > &xChanges, const vector< int > &yChanges);
};
Figure::Figure() {
}
Figure::Figure(int type, const vector< int > &xChanges, const vector< int > &yChanges)
: type(type), xChanges(xChanges), yChanges(yChanges) {
}
//------------------------------------------------
char a[15][15];
vector< Figure > figures;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
vector< int > xChanges(4), yChanges(4);
xChanges[0] = 0;
xChanges[1] = 0;
xChanges[2] = 1;
xChanges[3] = 1;
yChanges[0] = 0;
yChanges[1] = 1;
yChanges[2] = 0;
yChanges[3] = 1;
figures.push_back(Figure(1, xChanges, yChanges));
xChanges[2] = 0;
xChanges[3] = 0;
yChanges[2] = 2;
yChanges[3] = 3;
figures.push_back(Figure(2, xChanges, yChanges));
xChanges[1] = 1;
xChanges[2] = 2;
xChanges[3] = 3;
yChanges[1] = 0;
yChanges[2] = 0;
yChanges[3] = 0;
figures.push_back(Figure(2, xChanges, yChanges));
xChanges[1] = 0;
xChanges[2] = 1;
xChanges[3] = 1;
yChanges[1] = 1;
yChanges[2] = -1;
yChanges[3] = 0;
figures.push_back(Figure(3, xChanges, yChanges));
xChanges[1] = 1;
xChanges[2] = 1;
xChanges[3] = 2;
yChanges[1] = 0;
yChanges[2] = 1;
yChanges[3] = 1;
figures.push_back(Figure(3, xChanges, yChanges));
xChanges[1] = 0;
xChanges[2] = 1;
xChanges[3] = 1;
yChanges[1] = 1;
yChanges[2] = 1;
yChanges[3] = 2;
figures.push_back(Figure(4, xChanges, yChanges));
xChanges[1] = 1;
xChanges[2] = 1;
xChanges[3] = 2;
yChanges[1] = 0;
yChanges[2] = -1;
yChanges[3] = -1;
figures.push_back(Figure(4, xChanges, yChanges));
xChanges[1] = 1;
xChanges[2] = 1;
xChanges[3] = 1;
yChanges[1] = -1;
yChanges[2] = 0;
yChanges[3] = 1;
figures.push_back(Figure(5, xChanges, yChanges));
xChanges[1] = 1;
xChanges[2] = 1;
xChanges[3] = 2;
yChanges[1] = 0;
yChanges[2] = 1;
yChanges[3] = 0;
figures.push_back(Figure(5, xChanges, yChanges));
xChanges[1] = 0;
xChanges[2] = 0;
xChanges[3] = 1;
yChanges[1] = 1;
yChanges[2] = 2;
yChanges[3] = 1;
figures.push_back(Figure(5, xChanges, yChanges));
xChanges[1] = 1;
xChanges[2] = 1;
xChanges[3] = 2;
yChanges[1] = -1;
yChanges[2] = 0;
yChanges[3] = 0;
figures.push_back(Figure(5, xChanges, yChanges));
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
int cnt[] = {0, 0, 0, 0, 0, 0};
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(a[i][j] != '.') {
for(Figure f : figures) {
bool isOk = true;
for(int p = 1; p < 4; p++) {
if(i + f.xChanges[p] >= 0 && i + f.xChanges[p] < n) {
if(j + f.yChanges[p] >= 0 && j + f.yChanges[p] < m) {
if(a[i + f.xChanges[p]][j + f.yChanges[p]] != a[i][j]) {
isOk = false;
}
}
else {
isOk = false;
}
}
else {
isOk = false;
}
}
if(isOk) {
for(int p = 0; p < 4; p++) {
a[i + f.xChanges[p]][j + f.yChanges[p]] = '.';
}
cnt[f.type]++;
break;
}
}
}
}
}
for(int i = 1; i <= 5; i++) {
cout << cnt[i] << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |