본문 바로가기

Computer Science

(251)
vector & dequeue & list 1. vector 저장 원리 : 백터는 일반적인 배열처럼 연속된 메모리 공간을 찾아서 잡고 배열처럼 차근차근 인덱스로 저장한다. 이 말은 즉 배열처럼 operator[]로 접근이 가능하다는 소리이다. 즉 백터는 동적으로 확장/가능이 가능한 dynamic array로 구현되어 있다. 강점 : 1) 배열처럼 constant time 안에 인덱스 접근이 가능하다. 2)끝 부분에 삽입하는 연산은 reallocating이 발생하지 않는 한 constat time이다. reallocating 발생한다 하더라도 amortised constant time안에 수행가능하다. 3)일반적으로 vector는 list와 dequeue보다 random access time과 끝에서의 삽입 삭제가 빠르다. (하지만 상황이 어떠느냐..
백준 2667 단지 번호 #include #include #include using namespace std; typedef struct { int position_x; int position_y; }apartment; int Map[25][25]; bool visit[25][25]; int N; queue q; priority_queue pq; int dirx[4] = {0,0,1,-1}; int diry[4] = {-1,1,0,0}; void Input() { scanf("%d", &N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { scanf("%1d", &Map[i][j]); } } } void Calc() { for (int i = 0; i < N; i++)..
백준 7576 토마토 그냥 눈대중으로 풀었다. 첫번째로 푼것 : #include #include #include #include #include using namespace std; typedef struct { int position; int time; }tomato; int M, N; int Map[1000][1000]; queue q; int min_count; int dirx[4] = { 0,0,1,-1 }; int diry[4] = { -1,1,0,0 }; clock_t start, endi; void Input() { scanf("%d %d", &M, &N); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { scanf("%d", &Map[i][j]); if..