이름부터 삐뚤빼뚤 도미노스럽다.
주의 할점은 비어있는 공간을 찾을때 위에서부터(0번행) 끝까지 내려간다는 것이다. 그래야 최대한 내려갔을때, 그 위는 비어있는 공간이라는 것이 보장된다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int simulator(vector < vector<int> >& board, int col,int t) {
int line = 0;
int line_min = -1;
int line_min2 = -1;
for (int i = 0; i < 6; i++) {
if (board[i][col] == 0) {
line_min = i;
}
else break;
}
if (t == 2) {
for (int i = 0; i < 6; i++) {
if (board[i][col + 1] == 0) {
line_min2 = i;
}
else break;
}
line_min = min(line_min, line_min2);
}
board[line_min][col] = 1;
if (t == 2) board[line_min][col + 1] = 1;
if (t == 3) board[line_min - 1][col] = 1;
//이제 줄 조사
int deleted_row = -1;
for (int i = 0; i < 6; i++) {
bool all = true;
for (int j = 0; j < 4; j++) {
if (board[i][j] == 0) all = false;
}
if (all) {
if (deleted_row < i) deleted_row = i;
line++;
for (int j = 0; j < 4; j++) board[i][j] = 0;
}
}
if (line > 0) {
for (int i = deleted_row; i >= 0; i--) {
for (int j = 0; j < 4; j++) {
board[i][j] = 0;
if (i - line >= 0) board[i][j] = board[i - line][j];
}
}
}
int cnt = 0;
for (int i = 0; i < 2; i++) {
bool ex = false;
for (int j = 0; j < 4; j++) {
if (board[i][j] != 0) ex = true;
}
if (ex) cnt++;
}
if (cnt > 0) {
for (int i = 5; i >= 0; i--) {
for (int j = 0; j < 4; j++) {
board[i][j] = 0;
if (i - cnt >= 0) board[i][j] = board[i - cnt][j];
}
}
}
return line;
}
int main() {
//freopen("in1.txt", "rt", stdin);
vector < vector<int> > green(6, vector<int>(4));
vector<vector<int>> blue(6, vector<int>(4));
int n;
cin >> n;
int cnt = 0;
while (n--) {
int t, x, y;
cin >> t >> x >> y;
cnt += simulator(green, y, t);
if(t==2) cnt += simulator(blue, x, 3);
else if(t==3) cnt += simulator(blue, x, 2);
else cnt += simulator(blue, x, 1);
}
cout << cnt << '\n';
int ans = 0;
for (int i = 2; i < 6; i++) {
for (int j = 0; j < 4; j++) {
ans += green[i][j];
ans += blue[i][j];
}
}
cout << ans << '\n';
return 0;
}