본문 바로가기

Programming/Algorithm 193

백준 14503 로봇 청소기 #include #define MAX 51using namespace std; int map[MAX][MAX];int m, n;int x, y, d;int dx[4] = { -1, 0, 1, 0 };int dy[4] = { 0, 1, 0, -1 }; void input() {scanf("%d %d", &n, &m);scanf("%d %d %d", &x, &y, &d); for (int i = 0; i < n; i++)for (int j = 0; j < m; j++)scanf("%d", &map[i][j]);} int turn(int now, int next) {if (next == 0){if (now == 0) return 3;else if (now == 1) return 0;else if (now ==.. 2017. 10. 20.
백준 14499 주사위 굴리기 #include #include using namespace std; int n, m, x, y, k, nx, ny;int map[20][20], karray[1001], dice[5];int dx[4] = { 0, 0, -1, 1 }; // East, West, North, Southint dy[4] = { 1, -1, 0, 0 }; void dice_move(int d) {switch (d) {case 0: // Eastswap(dice[1], dice[2]);swap(dice[4], dice[5]);swap(dice[2], dice[5]);break;case 1: // Westswap(dice[4], dice[5]);swap(dice[1], dice[2]);swap(dice[1], dice[4]);.. 2017. 10. 20.
백준 1987 알파벳 #include #include #include using namespace std;int dx[] = { 0, 0, 1, -1 };int dy[] = { 1, -1, 0, 0 };int go(vector &board, vector &check, int x, int y) {int ans = 0;for (int k = 0; k= 0 && nx = 0 && ny < board[0].size()) {if (check[board[nx][ny] - 'A'] == false) {check[board[nx][ny] - 'A'] = true;int next = go(board, check, nx, ny);if (ans < next) {ans = next;}check[board[n.. 2017. 10. 20.
Breadth First Search BFS #include int n;int rear, front;int map[30][30], queue[30], visit[30]; void BFS(int v) {int i;visit[v] = 1; printf("%d start\n", v);queue[rear++] = v;while (front < rear) {v = queue[front++];for (int i = 1; i 2017. 10. 18.
Binary Search / Breadth First Search / Depth First Search Binary Search #include using namespace std; int BinarySearch(int dataArr[], int size, int findData) {int low = 0, high = size - 1, mid;while (low findData) high = mid - 1;else if (dataArr[mid] < findData) low = mid + 1;else return mid;}return -1;} int main(){int dataArr[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,24 };int length = sizeof(dataArr) / sizeof(dataArr[0]);int input, r.. 2017. 10. 18.
정렬 각종 정렬 알고리즘을 소개하고자 합니다. 알고르짐을 코드 레벨에서 분석만 한다면 지루할 수 있습니다. 이보다는 각각의 알고리즘이 갖는 특징에 관심을 두고 공부하는 것이 오래 남고 더 의미가 있을 것입니다. 버블 정렬 이해와 구현버블 정렬은 정렬의 대명사로 알려져 있는, 여러분이 알고 있을만한 정렬방법입니다. 이해하기도 구현하기도 쉽습니다. 물론 이해와 구현이 쉬운 만큼 성능에는 아쉬움이 있습니다. 그럼 3, 2, 4, 1이 순서대로 저장된 다음 그림의 배열을 오름차순(값이 클수록 뒤에 위치시키는 방법)으로 정렬하는 과정을 보이면서 버블 정렬의 과정을 소개하겠습니다. 버블 정렬은 인접한 두 개의 데이터를 비교해가면서 정렬을 진행하는 방식입니다. 두 데이터를 비교하여, 정렬순서상 위치가 바뀌어야 하는 경우에.. 2017. 8. 10.
트리(Tree) 트리는 고급 자료구조로 구분이 됩니다. 트리의 접근트리는 계측정 관계를 표현하는 자료구조입니다. 자료구조는 근본적으로 무엇인가를 표현하는 도구입니다. 트리의 구조로 이뤄진 무엇인가를 표현하기에 적절히 정의되어 있나요. 트리를 이용해서 무엇인가를 저장하고 꺼내야 한다는 생각을 지우세요. 대신 무엇인가를 표현하는 도구라고 생각하세요. 노드는 트리의 구성요소에 해당하는 A, B, C, D, E, F,와 같은 요소입니다. 간선은 노드와 노드를 연결하는 연결선을 말합니다. 루트 노드는 트리 구조에서 최상위에 존재하는 A와 같은 노드입니다. 단말 노드는 아래로 또 다른 노드가 연결되어 있지 않은 E, F, C, D와 같은 노드입니다. 내부 노드는 단말 노드를 제외한 모든 노드로 A, B와 같은 노드입니다. 이진 트.. 2017. 8. 3.
How to computer recongizes the image 1. Summary I would like to introduce facial recognition technology, which is my research area currently. To understand the face recognition field, we need to a basic knowledge of linear algebra, machine learning, and computer vision. This report focuses on how computers perceive images. Also, I will explain the BoF method that are typically used in many ways. This report is intended for beginner.. 2017. 6. 11.
알고리즘 공부 순서 1. 초,중,고 정보 올림피아드 문제풀이2. COCI 문제풀이3. USACO 문제풀이4. 영어 원서 Introduction of Algorithm5. 풀이가 있는 문제 세트 찾아서 공부하기.6. 종만북 문제풀이 2017. 5. 23.
1 demension Array example code /*배열을 이해하기.5개의 변수를 선언하고 변수값을 넣고나서 평균구하기.하는 이유. 기본적인 작성 코드에 대해 익숙해지기.*/ #include int main(void) {double total;double val[5]; // double 형 배열 선언 val[0] = 1.01;val[1] = 2.02;val[2] = 3.03;val[3] = 4.04;val[4] = 5.05;//val[5] = 6.06; total = val[0] + val[1] + val[2] + val[3] + val[4];printf("평균: %lf\n", total / 5); return 0;} 2017. 3. 9.