본문 바로가기

Algorithm/Dovelet

[Queue(BFS)] 댐/dam Question 30 계단 > 큐 > 댐(dam) Solving Code1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889#include using namespace std; typedef struct position{ int posX; int posY; int order;}pos; int t, map[103][103], sX, sY, k;pos queue[10000], tmp;int front, rear, cnt, key; int dirx[] = { -1.. 더보기
[Stack 응용]접시 꺼내기 / dish Question 문제 링크 Solving CodeColored By Color Scripter™12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#include #include #pragma warning(disable:4996) using namespace std; stack washing;char dish[32];int flag, cnt_all, cnt_answer, cnt_dish, start_alpha;int answer[1000000];void algo(int dishnum, int alpha); // 다음 결과 접시;int.. 더보기
[Algorithm]개미(koi_ant) 1. Questionhttp://183.106.113.109/pool/koi_ant/koi_ant.php?pname=koi_ant2. Discussion단순히 개미의 위치를 한칸씩 옮기는 방법으로 일부 테스트 케이스는 통과할 수 있을 것이다. 그러나 계산할 시간 t의 범위가 2,000,000,000개까지 나올 수 있으므로 좀 더 효율적인 방법을 생각해낼 필요가 있다. 3. Code 더보기
[Algorithm]전깃줄 (koi_Ewire) / 29% Question - 전깃줄 (koi_Ewire) http://183.106.113.109/pool/koi_Ewire/koi_Ewire.php?pname=koi_Ewire Explanation 1) 선들과 가장 많이 걸쳐 있는 선부터 삭제한다.2) LCS 알고리즘을 이용한다. 최장 공통 부분 수열 위키피디아Code Coding 더보기
공약수(koi_numM1)/옥상 Question http://183.106.113.109/pool/koi_numM1/koi_numM1.php?pname=koi_numM1 Code Colored By Color Scripter™123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include #pragma warning(disable:4996) int a, b, ans_a, ans_b;void algo(int *gcd, int *lcm);int gcd1(int ga, int gb); int main(){ scanf("%d %d", &a, &b); algo(&a, &b); return 0;} void algo(int *gcd, int .. 더보기
섞기 수열/koi_orbit (16 %) (coding) 문제 http://183.106.113.109/pool/koi_orbit/koi_orbit.php?pname=koi_orbit 풀이 처음엔 단순 코딩 문제라 생각하고 막 코딩했는데...입력값 n이 100을 넘어가니 time limit이 뜬다.Colored By Color Scripter™1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#include #include #pragma warning(disable:4996)int n, arr[20005], orbit[20005], sort[20005], temp[20005];int cmp();int main(){ scanf(".. 더보기
josephus / 통과율(51%) 문제 http://183.106.113.109/30stair/josephus/josephus.php?pname=josephus 코드 Colored By Color Scripter™123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102#include #include #include using namespace std; typedef struct _node{ int num; struct _node* prev; s.. 더보기
Block/통과율(61%) 문제 http://183.106.113.109/30stair/block/block.php?pname=block Code Colored By Color Scripter™123456789101112131415161718192021222324252627282930313233343536373839#include #include using namespace std; int arr[11][11];void sumPart(int i, int j); int main(){ for (int i = 1; i arr[j][i]; } for (int i = 1; i 더보기
속임수/coci_trik/통과율(63%) 문제: http://183.106.113.109/30stair/coci_trik/coci_trik.php?pname=coci_trik 문제 요약 컵이 3개 있고, 최초 왼쪽 컵에 공을 넣었다. 이리저리 섞은 후 최후에 공이 들어 있는 컵을 맞추는 문제다. 인풋값으로 A, B 또는 C가 주어질 수 있고, 최대 50번까지 섞는게 가능하다. A는 왼쪽과 중간 컵의 위치를 바꾸는 것이다.B는 중간과 오른쪽 컵의 위치를 바꾸는 것이다.C는 왼쪽과 오른쪽 컵의 위치를 바꾸는 것이다. Code 12345678910111213141516171819202122232425262728293031323334353637383940414243#include #pragma warning(disable:4996) char order.. 더보기
[Dynamic Programming]scv 자원 채취 문제 문제로 가기 -> http://183.106.113.109/30stair/scv/scv.php?pname=scv난이도: 하 프로그램 명: scv제한시간: 1 초N * N 크기의 맵이 있다. 이 맵에는 미네랄이 군데군데 매장되어 있어서 당신은 SCV 를 이용해 이 미네랄을 채취하려고 한다.SCV 는 (1,1) 의 위치에서 출발하여 (N,N)까지 이동하는데, 이 SCV 는 고물이라 오른쪽 또는 아래쪽으로 밖에 움직이지 못한다. 이 SCV 는 무한한 양의 미네랄을 가지고 있을 수 있다고 가정하자. 이 SCV 를 이용해서 최대한 많이 미네랄을 얻도록 하는 프로그램을 작성하시오.입력 방법첫 줄에는 맵의 크기 N ( 3 더보기