목록ALGORITHM/BAEKJOON (76)
MY MEMO
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { string input; cin >> input; int n = input.size(); int start, end; int answer = 2e9; for (int x = n - 1; x >= 0; x--) { start = x; end = x + 1; while (start >= 0 && end < n) { if (input[start] != input[end]) break; start--; end++; } if (end == n) answer = min(answer, start + 1); start = x - 1; end = x + 1..
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; //시간초과..... //초기화는 무조건 -1 int n; vectorCard(2, vector(2001)); vectorDP(2001, vector(2001, -1)); long long Game(int left,int right) { if (left == n || right == n) return 0; long long &ret = DP[left][right]; if (ret != -1) return ret; int num1 = 0, num2 = 0, num3 = 0; num1 = Game(left + 1, right); num2 = Game(left + 1,..
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { vectorisPaline(2501, vector(2501, 0)); vectorDP(2501, 0); string input; cin >> input; int input_size = input.size(), start, end; for (int x = 0; x -1 && end < input_size) { if (input[start..
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; //각 동전 당 개수가 정해져있음 //경우의 수를 구함 //중복을 방지하기 위해 큰 수부터 int main() { vectorDP(10001); vectormap(101); int cost, n; scanf("%d %d", &cost, &n); DP[0] = 1; for (int j = 1; j
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { string answer, angel, devil; cin >> answer >> angel >> devil; vectorAngel(101, vector(101, 0)), Devil(101, vector(101, 0)); int ans_count = answer.size(); int bridge_count = angel.size(); Angel[0][0] = 1; Devil[0][0] = 1; for (int x = 1; x
#define _CRT_SECURE_NO_WARNINGS #include #include #include #include using namespace std; int main() { string input1, input2; cin >> input1 >> input2; int size1 = input1.size(), size2 = input2.size(); vectorDP(4001, vector(4001, 0)); int answer = 0; for (int index1 = 0; index1 < size1; index1++) { for (int index2 = 0; index2 < size2; index2++) { if (input1[index1] == input2[index2]) { if (index1 ..
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { int for_count, n, input; scanf("%d", &for_count); while (for_count--) { vectorsum(501); vectorDP(501, vector(501)); scanf("%d", &n); for (int x = 1; x
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { int size, input, j; scanf("%d", &size); vectord(1001); vectorM(1001, vector(1001)); for (int j = 0; j < size; j++) { if (j == 0) scanf("%d %d", &d[0], &d[1]); else scanf("%d %d", &input, &d[j + 1]); } for (int diagonal = 0; diagonal < size; diagonal++) { for (int i = 1; i + diagonal
#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { int n; scanf("%d", &n); vectormap(40001), DP(40001, 0); for (int j = 0; j < n; j++) scanf("%d", &map[j]); int Max = 0; for (int j = 0; j < n; j++) { Max = 0; for (int k = 0; k < j; k++) { if (map[k] < map[j]) Max = max(Max, DP[k]); } DP[j] = Max + 1; } Max = 0; for (int j = 0; j < n; j++) Max = max(Max, ..
#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; int main() { vectormap(101); int n,input; scanf("%d", &n); vectorDP(101, vector(21,0)); scanf("%d", &input); DP[0][input]++; for (int x = 1; x < n - 1; x++) { scanf("%d", &input); for (int y = 0; y < 21; y++) { if (DP[x - 1][y] != 0) { if (input + y = 0) DP[x][input + y]+=DP[x-1][y]; if (y - input = 0) DP[x][y-input] += DP[x ..