# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652171 | 4EVER | Tetris (COCI17_tetris) | C++11 | 1 ms | 340 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.
/******************************
* author : @yayayaya *
* date : 21 / 10 / 2022 *
******************************/
/* (≈ㅇᆽㅇ≈)♡ (≈ㅇᆽㅇ≈)♡ (≈ㅇᆽㅇ≈)♡ (≈ㅇᆽㅇ≈)♡ (≈ㅇᆽㅇ≈)♡ */
/*
/^--^\ /^--^\ /^--^\
\____/ \____/ \____/
/ \ / \ / \
| | | | | |
\__ __/ \__ __/ \__ __/
|^|^|^|^|^|^|^|^|^|^|^|^\ \^|^|^|^/ /^|^|^|^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|
| | | | | | | | | | | | |\ \| | |/ /| | | | | |\ \| | | | | | | | | | | |
| | | | | | | | | | | | |/ /| | |\ \| | | | | |/ /| | | | | | | | | | | |
| | | | | | | | | | | | |\/ | | | \/| | | | | |\/ | | | | | | | | | | | |
#########################################################################
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | */
/*******************************************************************************************
* ################################################################# *
* # _` # *
* # _ooOoo_ # *
* # o8888888o # *
* # 88" . "88 # *
* # (| -_- |) # *
* # O\ = /O # *
* # ____/`---'\____ # *
* # .' \| |// `. # *
* # / \||| : |||// \ # *
* # / _||||| -:- |||||_ \ # *
* # | | \ - /'| | | # *
* # | \_| `\`---'// |_/ | # *
* # \ .-\__ `-. -'__/-. / # *
* # ___`. .' /--.--\ `. .'___ # *
* # ."" '< `.___\_<|>_/___.' _> \"". # *
* # | | : `- \`. ;`. _/; .'/ / .' ; | # *
* # \ \ `-. \_\_`. _.'_/_/ -' _.' / # *
* #=============`-.`___`-.__\ \___ /__.-'_.'_.-'=================# *
* `=--=-' *
* *
* /\_/\* *
* ( -.-) *
* _.-/`) / >O \>1 _.-/`) *
* // / / ) // / / ) *
* .=// / / / ) /\_/\ /\_/\ .=// / / / ) *
* //`/ / / / / ( -.-) ( -.-) //`/ / / / / *
* // / ` / / >O \>1 / >O \>1 // / ` / *
* \ / \ / *
* )) .' /\_/\ /\_/\ /\_/\ )) .' *
* // / ( -.-) ( -.-) ( -.-) // / *
* / / >O \>1 / >O \>1 / >O \>1 / *
* *
*******************************************************************************************/
#include <bits/stdc++.h>
// #pragma GCC optimize("O2")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize ("O3,unroll-loops,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define PB push_back
#define ALL(i_) i_.begin(), i_.end()
#define LOG2(x) (31 - __builtin_clz(x))
#define getBit(x, i) ((x >> i) & 1)
#define rd(l, r) (l + rng() % (r - l + 1))
#define FOR(i_, a_, b_) for(int i_ = (int) (a_); i_ <= (int) (b_); ++i_)
#define FORD(i_, a_, b_) for(int i_ = (int) (a_); i_ >= (int) (b_); --i_)
#define db(val) "["#val" = "<<(val)<<"] "
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
template<class X, class Y> bool minimize(X &x, const Y &y){
X eps = 1e-9;
if (x > y + eps) {
x = y;
return 1;
}
return 0;
}
template<class X, class Y> bool maximize(X &x, const Y &y) {
X eps = 1e-9;
if (x + eps < y) {
x = y;
return 1;
}
return 0;
}
template<class T> T Abs(const T &x) { return (x < 0 ? -x : x); }
const int mod = (int) 1e9 + 7;
const int oo = (int) 1e9 + 99;
const int maxn = (int) 22;
const int LOG = (int) 20;
const ii dxy8[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1}, {1, -1}, {1, 1}, {-1, 1}, {-1, -1} };
const ii dxy4[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
int n, m;
char a[maxn][maxn], b[maxn][maxn];
int vs[maxn][maxn];
vector<ii> figure;
int res[5];
void DFS(int u, int v){
figure.PB({u, v});
vs[u][v] = 1;
FOR(i, 0, 3){
int p = u + dxy4[i].first;
int q = v + dxy4[i].second;
if(p >= 1 && p <= max(n, m) && q >= 1 && q <= max(n, m)){
if(!vs[p][q] && a[p][q] == a[u][v]) DFS(p, q);
}
}
}
void solve(){
int cnt = 0;
sort(ALL(figure));
vector<vector<int>> mark(n + 11, vector<int>(m + 11, 0));
FOR(i, 0, 3) mark[figure[i].first][figure[i].second] = 1;
int u = figure[0].first;
int v = figure[0].second;
int cnt_0 = 0;
cnt_0 += (mark[u + 1][v] + mark[u][v + 1] + mark[u + 1][v + 1]);
if(cnt_0 == 3) ++res[0];
int cnt_1 = 0;
cnt_1 += (mark[u][v + 1] + mark[u][v + 2] + mark[u][v + 3]);
if(cnt_1 == 3) ++res[1];
int cnt_2 = 0;
cnt_2 += (mark[u][v + 1] + mark[u + 1][v] + mark[u + 1][v - 1]);
if(cnt_2 == 3) ++res[2];
int cnt_3 = 0;
cnt_3 += (mark[u][v + 1] + mark[u + 1][v + 1] + mark[u + 1][v + 2]);
if(cnt_3 == 3) ++res[3];
int cnt_4 = 0;
cnt_4 += (mark[u + 1][v] + mark[u + 1][v - 1] + mark[u + 1][v + 1]);
if(cnt_4 == 3) ++res[4];
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TASK "TETRIS"
if(fopen(TASK".inp", "r")) {
freopen(TASK".inp", "r", stdin);
freopen(TASK".out", "w", stdout);
}
cin >> n >> m;
FOR(i, 0, max(n, m)){
FOR(j, 0, max(n, m)) a[i][j] = '.';
}
FOR(i, 1, n){
FOR(j, 1, m) cin >> a[i][j];
}
FOR(k, 0, 3){
FOR(i, 1, max(n, m)){
FOR(j, 1, max(n, m)){
b[j][max(n, m) - i + 1] = a[i][j];
}
}
memset(vs, 0, sizeof vs);
FOR(i, 1, max(n, m)) FOR(j, 1, max(n, m)) if(!vs[i][j] && (a[i][j] != '.')){
figure.clear();
DFS(i, j);
solve();
}
FOR(i, 1, max(n, m)){
FOR(j, 1, max(n, m)){
a[i][j] = b[i][j];
}
}
}
cout << res[0] / 4 << "\n";
cout << res[1] / 2 << "\n";
cout << res[2] / 2 << "\n";
cout << res[3] / 2 << "\n";
cout << res[4] << "\n";
return 0;
}
/// CONCACOCONCACOCONCACOCONCACOCONCACOCONCACOCONCACOCONCACOCONCACO ///
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |