# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
237202 | DIvanCode | Tetris (COCI17_tetris) | C++14 | 5 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<ctime>
#include<cassert>
#include<complex>
#include<string>
#include<cstring>
#include<chrono>
#include<random>
#include<bitset>
#include<iomanip>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int N = 30;
int n, m;
char a[N][N];
int ans[N];
bool check1(int i, int j) {
set<char> colors;
vector<set<char>> vars;
colors = {a[i][j], a[i - 1][j], a[i - 1][j + 1], a[i][j + 1]};
vars.eb(colors);
for (auto &colors : vars) {
if (sz(colors) == 1) {
return true;
}
}
return false;
}
bool check2(int i, int j) {
set<char> colors;
vector<set<char>> vars;
colors = {a[i][j], a[i][j + 1], a[i][j + 2], a[i][j + 3]};
vars.eb(colors);
colors = {a[i][j], a[i - 1][j], a[i - 2][j], a[i - 3][j]};
vars.eb(colors);
for (auto &colors : vars) {
if (sz(colors) == 1) {
return true;
}
}
return false;
}
bool check3(int i, int j) {
set<char> colors;
vector<set<char>> vars;
colors = {a[i][j], a[i][j + 1], a[i - 1][j + 1], a[i - 1][j + 2]};
vars.eb(colors);
colors = {a[i][j], a[i - 1][j], a[i - 1][j - 1], a[i - 2][j - 1]};
vars.eb(colors);
for (auto &colors : vars) {
if (sz(colors) == 1) {
return true;
}
}
return false;
}
bool check4(int i, int j) {
set<char> colors;
vector<set<char>> vars;
colors = {a[i][j], a[i][j + 1], a[i + 1][j + 1], a[i + 1][j + 2]};
vars.eb(colors);
colors = {a[i][j], a[i - 1][j], a[i - 1][j + 1], a[i - 2][j + 1]};
vars.eb(colors);
for (auto &colors : vars) {
if (sz(colors) == 1) {
return true;
}
}
return false;
}
bool check5(int i, int j) {
set<char> colors;
vector<set<char>> vars;
colors = {a[i][j], a[i + 1][j - 1], a[i + 1][j], a[i + 1][j + 1]};
vars.eb(colors);
colors = {a[i][j], a[i - 1][j - 1], a[i - 1][j], a[i - 1][j + 1]};
vars.eb(colors);
colors = {a[i][j], a[i - 1][j + 1], a[i][j + 1], a[i + 1][j + 1]};
vars.eb(colors);
colors = {a[i][j], a[i - 1][j - 1], a[i][j - 1], a[i + 1][j - 1]};
vars.eb(colors);
for (auto &colors : vars) {
if (sz(colors) == 1) {
return true;
}
}
return false;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < N; ++i) {
fill(a[i], a[i] + N, '#');
}
for (int i = 5; i <= n + 4; ++i) {
for (int j = 5; j <= m + 4; ++j) {
cin >> a[i][j];
}
}
for (int i = 5; i <= n + 4; ++i) {
for (int j = 5; j <= m + 4; ++j) {
if (a[i][j] == '.') continue;
if (check1(i, j)) ans[1]++;
if (check2(i, j)) ans[2]++;
if (check3(i, j)) ans[3]++;
if (check4(i, j)) ans[4]++;
if (check5(i, j)) ans[5]++;
}
}
for (int i = 1; i <= 5; ++i) {
cout << ans[i] << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |