# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105495 | leonarda | Tetris (COCI17_tetris) | C++14 | 3 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
const int maxn = 15;
int n, m;
char a[maxn][maxn];
bool memo[maxn][maxn];
int cnt[5];
bool fuki1(int x, int y, char c) {
if(c == a[x + 1][y] and c == a[x][y + 1] and c == a[x + 1][y + 1]) {
memo[x][y] = memo[x + 1][y] = memo[x][y + 1] = memo[x + 1][y + 1] = 1;
return 1;
}
return 0;
}
bool fuki2(int x, int y, char c) {
if(a[x + 1][y] == c and a[x + 2][y] == c and a[x + 3][y] == c) {
memo[x][y] = memo[x + 1][y] = memo[x + 2][y] = memo[x + 3][y] = 1;
return 1;
}
if(c == a[x][y + 1] and c == a[x][y + 2] and c == a[x][y + 3]) {
memo[x][y] = memo[x][y + 1] = memo[x][y + 2] = memo[x][y + 3] = 1;
return 1;
}
return 0;
}
bool fuki3(int x, int y, char c) {
if(c == a[x + 1][y] and c == a[x][y + 1] and c == a[x + 1][y - 1]) {
memo[x][y] = memo[x][y + 1] = memo[x + 1][y] = memo[x + 1][y - 1] = 1;
return 1;
}
if(c == a[x + 1][y] and c == a[x + 1][y + 1] and c == a[x + 2][y + 1]) {
memo[x][y] = memo[x + 1][y] = memo[x + 1][y + 1] = memo[x + 2][y + 1] = 1;
return 1;
}
return 0;
}
bool fuki4(int x, int y, char c) {
if(c == a[x][y + 1] and c == a[x + 1][y + 1] and c == a[x + 1][y + 2]) {
memo[x][y] = memo[x][y + 1] = memo[x + 1][y + 1] = memo[x + 1][y + 2] = 1;
return 1;
}
if(c == a[x + 1][y] and c == a[x + 1][y - 1] and c == a[x + 2][y - 1]) {
memo[x][y] = memo[x + 1][y] = memo[x + 1][y - 1] = memo[x + 2][y - 1] = 1;
return 1;
}
return 0;
}
bool fuki5(int x, int y, char c) {
if(c == a[x + 1][y] and c == a[x + 1][y - 1] and c == a[x + 1][y + 1]) {
memo[x][y] = memo[x + 1][y + 1] = memo[x + 1][y - 2] = memo[x + 1][y] = 1;
return 1;
}
if(c == a[x + 1][y] and c == a[x + 1][y - 1] and c == a[x + 2][y]) {
memo[x][y] = memo[x + 1][y] = memo[x + 1][y - 1] = memo[x + 2][y] = 1;
return 1;
}
if(c == a[x + 1][y] and c == a[x + 2][y] and c == a[x + 1][y + 1]) {
memo[x][y] = memo[x + 1][y] = memo[x + 2][y] = memo[x + 1][y + 1] = 1;
return 1;
}
if(c == a[x][y + 1] and c == a[x][y + 2] and c == a[x + 1][y + 1]) {
memo[x][y] = memo[x][y + 1] = memo[x][y + 2] = memo[x + 1][y + 1] = 1;
return 1;
}
return 0;
}
int main ()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
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] != '.' and not memo[i][j]) {
// cout << i << " " << j << endl;
if(fuki1(i, j, a[i][j])) {
// cout << 1 << endl;
cnt[0]++;
} else if(fuki2(i, j, a[i][j])) {
// cout << 2 << endl;
cnt[1]++;
} else if(fuki3(i, j, a[i][j])) {
// cout << 3 << endl;
cnt[2]++;
} else if(fuki4(i, j, a[i][j])) {
// cout << 4 << endl;
cnt[3]++;
} else if(fuki5(i, j, a[i][j])) {
// cout << 5 << endl;
cnt[4]++;
}
}
}
}
for(int i = 0; i < 5; ++i) {
if(i) cout << endl;
cout << cnt[i];
}
return 0;
}
//pcelica maja
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |