07-03 06:29
벤치마킹
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 양양솔비치세프스키친
- 고마워다음
- 에어아시아
- 양양솔비치조식
- 가족소고기외식
- 푸르지오포레피스
- 오트눈썰매장
- 영통칠프로칠백식당
- DFS
- 사진문자추출
- 결항전문
- 싱가폴중학교수학문제
- 아이혼자다녀옴
- 중학교입학수학문제
- 양양솔비치아침
- 양양솔비치 뷔페
- 주차넉넉
- 검색완료
- 영통역소고기
- 편도수술
- 홍시스무디
- 커피
- 사진문자추출하기
- 당근마켓중고차
- 결항
- 커피쏟음
- 파이썬
- 종이캐리어
- 사진에서 글자추출
- 영통외식
Archives
- Today
- Total
너와나의 관심사
뿌요뿌요 c code 본문
#include <stdio.h>
char py[12][7], visit[12][7];
int cb;
#define MAX_H 12
#define MAX_W 6
#define MAX_NUM MAX_W * MAX_H
typedef struct s_info{
int x;
int y;
char CH;
}Sinfo;
Sinfo Stackbuf[MAX_NUM + 1];
int stackcnt = 0;
int Push(Sinfo info){
if (stackcnt > MAX_NUM - 1)
return -1;
Stackbuf[stackcnt++] = info;
return stackcnt;
}
Sinfo Pop(void){
return Stackbuf[--stackcnt];
}
void Clear(void){
stackcnt = 0;
}
void mark(void){
Sinfo info_pop;
while (stackcnt > 0) {
info_pop = Pop();
py[info_pop.y][info_pop.x] = '.';
}
Clear();
}
void drop() {
int i, j, k;
for (j = 0; j <= 5; j++) {
for (i = 11; i >= 0; i--) {
if (py[i][j] == '.') {
for (k = i - 1; k >= 0 && py[k][j] == '.'; k--);
if (k >= 0) {
py[i][j] = py[k][j];
py[k][j] = '.';
}
}
}
}
}
int find(int x, int y, char CH) {
if (x < 0 || x > 5 || y < 0 || y > 11 || py[y][x] != CH || visit[y][x] == cb) return 0;
visit[y][x] = cb;
if (CH == '.') return 0;
int cnt = 1;
Sinfo info;
info.x = x;
info.y = y;
info.CH = CH;
Push(info);
cnt += find(x + 1, y, CH);
cnt += find(x - 1, y, CH);
cnt += find(x, y + 1, CH);
cnt += find(x, y - 1, CH);
return cnt;
}
int main() {
int i, j;
char flg = 1;
//freopen("input.txt", "r", stdin);
for (i = 0; i < 12; i++) scanf("%s", py[i]);
for (cb = 1; flg; cb++) {
flg = 0;
for (i = 0; i <= 11; i++) {
for (j = 0; j <= 5; j++) {
if (find(j, i, py[i][j]) >= 4) {
flg = 1;
mark();
}
else {
Clear();
}
}
}
drop();
}
printf("%d\n", cb - 2);
}
char py[12][7], visit[12][7];
int cb;
#define MAX_H 12
#define MAX_W 6
#define MAX_NUM MAX_W * MAX_H
typedef struct s_info{
int x;
int y;
char CH;
}Sinfo;
Sinfo Stackbuf[MAX_NUM + 1];
int stackcnt = 0;
int Push(Sinfo info){
if (stackcnt > MAX_NUM - 1)
return -1;
Stackbuf[stackcnt++] = info;
return stackcnt;
}
Sinfo Pop(void){
return Stackbuf[--stackcnt];
}
void Clear(void){
stackcnt = 0;
}
void mark(void){
Sinfo info_pop;
while (stackcnt > 0) {
info_pop = Pop();
py[info_pop.y][info_pop.x] = '.';
}
Clear();
}
void drop() {
int i, j, k;
for (j = 0; j <= 5; j++) {
for (i = 11; i >= 0; i--) {
if (py[i][j] == '.') {
for (k = i - 1; k >= 0 && py[k][j] == '.'; k--);
if (k >= 0) {
py[i][j] = py[k][j];
py[k][j] = '.';
}
}
}
}
}
int find(int x, int y, char CH) {
if (x < 0 || x > 5 || y < 0 || y > 11 || py[y][x] != CH || visit[y][x] == cb) return 0;
visit[y][x] = cb;
if (CH == '.') return 0;
int cnt = 1;
Sinfo info;
info.x = x;
info.y = y;
info.CH = CH;
Push(info);
cnt += find(x + 1, y, CH);
cnt += find(x - 1, y, CH);
cnt += find(x, y + 1, CH);
cnt += find(x, y - 1, CH);
return cnt;
}
int main() {
int i, j;
char flg = 1;
//freopen("input.txt", "r", stdin);
for (i = 0; i < 12; i++) scanf("%s", py[i]);
for (cb = 1; flg; cb++) {
flg = 0;
for (i = 0; i <= 11; i++) {
for (j = 0; j <= 5; j++) {
if (find(j, i, py[i][j]) >= 4) {
flg = 1;
mark();
}
else {
Clear();
}
}
}
drop();
}
printf("%d\n", cb - 2);
}
Comments