본문 바로가기

Computer Science304

Knuth-Morris-Pratt Pattern Matching (KMP) #include #include #define OUTPUT(x) printf("%d\n", x ) #define ASIZE 256 #define XSIZE 256 void preKmp(char* x, int m, int kmpNext[]) { int i, j; i = 0; j = kmpNext[0] = -1; while (i -1 && x[i] != x[j]) j = kmpNext[j]; i++; j++; if (x[i] == x[j]) kmpNext[i] = kmpNext[j]; else kmpNext[i] = j; } } void KMP(char* x, int m, char* y, int n) { int i, j, kmpNext[XSIZE]; /* Preprocessi.. 2021. 4. 24.
Morris-Pratt Pattern Matching #include #include #define OUTPUT(x) printf("%d\n", x ) void preMp(char* x, int m, int mpNext[]) { int i, j; i = 0; j = mpNext[0] = -1; while (i -1 && x[i] != x[j]) j = mpNext[j]; mpNext[++i] = ++j; } } void MP(char* x, int m, char* y, int n) { int i, j, mpNext[256]; /* Preprocessing */ preMp(x, m, mpNext); /* Searching */ i = j = 0; while (j -1 && x[i] != y[j].. 2021. 4. 24.
Shift Or pattern mathcing int preSo(char *x, int m, usinged int s[]){ usigned int j, lim; int i; for(i =0 ; i 2021. 4. 24.
CRC 개념 Cyclic Reduendacny Check 3비트 check sum 예제임. 송신부 11010011101100 1011 1100011101100 1011 111011101100 1011 10111101100 1011 00001101100 1011 110100 1011 11000 1011 1110 1011 1010 1011 100 수신부의 뒷자리에 100 을 추가해서 검사를 하면 됨. 그리고 똑같이 1011로 XOR 연산을 하면, 마지막에 000 으로 나옴. 중첩으로 해서 최종 CRC를 구해야 함 data[3] = {0x12, 0x34, 0x0}; crc = crc8(0xac^0x34) data[2] = crc = 0x94; void crc8_populate_msb(u8 *table, u8 polynom.. 2021. 4. 24.
State Pattern - The State Pattern allows an object to alter its behavior when its internal state changes. The object will appeaer to change its class. 2021. 4. 19.
TS 서점 const int BLM = 100001; const int ALM = 10001; const int GLM = 21; int AN; int GN; int income[ALM]; int atop[5]; bool Amax(int a, int b) { if(income[a] != income[b]) return income[a] > income[b]; return a < b; } template void swap(T& a, T& b) { T t = a; a = b; b = t; } struct Book { int sellCnt, stock, out, bid, gid, price, acnt, aids[5]; void setBook(int nb, int ng, int np, int nc, int* ap) { s.. 2021. 3. 31.
Heap에서 원하는 노드의 값 수정하기 (index를 관리하는 Heap 구현) 이전 프로 기출문제 댓글중에서 잠시 언급한적이 있는 "원하는 노드 값을 수정할 수 있는 Heap 자료구조"에 대한 내용입니다. 일단 우리가 흔히 알고있는 Heap (priority_queue)의 구현체는 다음과 같습니다. struct Heap { int n; int v[100009]; void inil() { n = 1; } void push(int value) { v[n] = value; n++; update(n - 1); } int pop() { n--; int res = v[1]; v[1] = v[n]; v[n] = res; downdate(1); return res; } int top() { return v[1]; } void update(int ti) { //update while (ti > 1.. 2021. 3. 29.
No. F : 케이크전문점 www.jungol.co.kr/xpert/contestproblem.php?bo_table=study&cid=1493&pid=6&al=005002&stx=6 http://www.jungol.co.kr/xpert/contestproblem.php?bo_table=study&cid=1493&pid=6&al=005002&stx=6 www.jungol.co.kr 1. update 할 때 순서 정렬은 init TimeStamp 2. update 했는지 안했는지, 얼마나 했는지 체크하여서 넣어둠 3. update 이전에 해당 timeStampe + updateMultiple 비교해서 넣어줌 현재 상태 -> update 부분 수정 필요, update 들어가기 전 수정 필요 timeStamp 800 일 때, apple.. 2021. 3. 22.
[H2104] 창고 관리 out.swexpertacademy.samsung.com/common/swea/solvingPractice/problemResult.do?contestProbId=AXdf-YkAShBqnWAH&ocwKind=&ocwSeq=&solveclubId=&solveclubPassword=&attendYn= Information Message Information Message 잠시만 기다려 주세요.만일 화면이 수분이상 멈출 경우,다음과 같이 조치하세요. 신뢰할 수 있는 사이트추가(도구-인터넷옵션-보안-신뢰할 수 있는사이트 - *.samsung.com추가) IE 버 out.swexpertacademy.samsung.com:443 - 구조체 사용 - 구조체, 포인터 사용 복습 필요 - 해쉬 사용을 유연하게. #def.. 2021. 3. 3.