Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions LimGeon/16236.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include <stdio.h>
#include <queue>
#include <windows.h>

using namespace std;

void initVisited();

typedef struct CUR {
int y, x;
int size;
int time;
}CUR;

int map[21][21];
int visited[21][21];
int dx[4] = { 0,-1,1,0 };
int dy[4] = { -1,0,0,1 };
int allTime = 0;
int sharkExp = 0;
int n;
int newStart = 0;

queue<CUR> q;


int main()
{
int startX, startY;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
scanf("%d", &map[i][j]);
if (map[i][j] == 9) {
startY = i;
startX = j;
map[i][j] = 0;
}
}
}

CUR StartShark = { startY,startX,2,0 };
q.push(StartShark);
while (!q.empty()) {

CUR NowShark = q.front();
printf("%d %d %d\n", NowShark.y+1, NowShark.x+1, NowShark.time);
q.pop();
for (int i = 0; i < 4; i++) {
CUR NextShark = { NowShark.y + dy[i],NowShark.x + dx[i],NowShark.size,NowShark.time+1 };
if (0 <= NextShark.y && NextShark.y < n && 0 <= NextShark.x && NextShark.x < n) {
if (0 < map[NextShark.y][NextShark.x] && map[NextShark.y][NextShark.x] < NextShark.size) {
//Sleep(1000);
allTime += NextShark.time;
sharkExp++;
map[NextShark.y][NextShark.x] = 0;

if (sharkExp == NextShark.size) {
sharkExp = 0;
NextShark.size++;
}
while (!q.empty()) q.pop();
newStart = 1;
if (q.empty() == 1) printf("ť�� ������ϴ�.\n");
NextShark.time = 0;
q.push(NextShark);
initVisited();
}
else if ((map[NextShark.y][NextShark.x] == 0 || map[NextShark.y][NextShark.x] == NextShark.size) && visited[NextShark.y][NextShark.x]==0) {
q.push(NextShark);
visited[NextShark.y][NextShark.x] = 1;
}
}
if (newStart == 1) {
newStart = 0;
break;
}
}
}
printf("%d", allTime);
return 0;
}

void initVisited() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
visited[i][j] = 0;
}
}
}
67 changes: 67 additions & 0 deletions LimGeon/17825_LimGeon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <stdio.h>

int mainPath[22] = { 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,0 };
int aPath[9] = { 10,13,16,19,25,30,35,40,0 };
int bPath[8] = { 20,22,24,25,30,35,40,0 };
int cPath[9] = { 30,28,27,26,25,30,35,40,0 };
int* pathPointer[4] = { mainPath,aPath,bPath,cPath };

typedef struct token {
int path;
int* loc;
}TOKEN;

int dice[10];
TOKEN token[4];
int maxPoint = 0;

void DFS(int cnt, int point);

int main()
{
for (int i = 0; i < 4; i++) {
token[i].path = 0;
token[i].loc = mainPath;
}
for (int i = 0; i < 10; i++)
scanf("%d", dice+i);

DFS(0,0);

printf("%d", maxPoint);
return 0;
}

void DFS(int cnt, int point)
{
TOKEN temp[4];
for (int i = 0; i < 4; i++) {
temp[i].path = token[i].path;
temp[i].loc = token[i].loc;
}
for (int i = 0; i < 4; i++) {
if (temp[i].path == 0) {
if (*(temp[i].loc) == 10) {
temp[i].path = 1;
temp[i].loc = aPath;
}
else if (*(token[i].loc) == 20) {
temp[i].path = 2;
temp[i].loc = bPath;
}
else if (*(token[i].loc) == 30) {
temp[i].path = 3;
temp[i].loc = cPath;
}
}
int* next = temp[i].loc + dice[cnt];
int index = next - pathPointer[temp[i].path];
if (cnt < 10 && ((temp[i].path == 0 && index < 21) || (temp[i].path == 1 && index < 8) || (temp[i].path == 2 && index < 7) || (temp[i].path == 3 && index < 8))) {
point += *next;
token[i].loc = next;
printf("token: %d, path: %d, index: %d\n", i, token[i].path, index);
if (maxPoint < point) maxPoint = point;
DFS(cnt + 1, point);
}
}
}