분류 전체보기

    [C++] 백준 9935 문자열 폭발

    #include #include using namespace std;int main(){ string N = ""; string target = ""; string result = ""; cin >> N >> target; int targetSize = target.size(); for(const auto& bomb : N) { result += bomb; if (result.back() == target.back() && result.size() >= targetSize) { string temp = result.substr(result.size() - targetSize, targetSize); if (temp == target) { result.erase(result.en..

    [C++] 백준 10816 숫자 카드2

    #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector table; int N, M, num; cin >> N; for (int i = 0; i > num; table.push_back(num); } sort(table.begin(), table.end()); cin >> M; for (int i = 0; i > num; cout  풀이1. vector에 저장하여 정렬해준다.2. 해당 수가 있는 처음과 끝의 차를 계산해서 몇개가 있는지를 확인한다.3. 아래의 입출력 최적화를 빼면 시간초과난..

    [C++] 백준 2225 합분해

    #include #include #include using namespace std;int main(){ int N = 0; int K = 0; cin >> N >> K; vector> lists(N, vector(K, 1)); for (int i = 1; i  느낀점답을 모두 list로 나열해보자지금까지 풀었던 dp 문제들을 생각해보니 과정을 점화식으로 만들기보다 답에서 패턴을 읽어서 점화식을 만들어 나가는 것같다. 다음에 풀때는 답을 먼저 만들고 패턴을 찾아봐야겠다. https://www.acmicpc.net/problem/2225

    [C++] 백준 14889 스타트와 링크

    #include #include using namespace std;int N = 0;int result = 1001;vector visited;vector> team;void DFS(int count, int num){ if (count == N / 2) { int start = 0; int link = 0; for (int i = 0; i > N; team = vector>(N, vector(N, 0)); visited = vector(N, false); //입력 for (int i = 0; i > team[i][j]; } } DFS(0, 0); cout  풀이1. DFS로 경우의 수들을 탐색한다.2. ..

    [C++] 백준 2579 계단 오르기

    #include #include using namespace std;int main(){ vector stair; vector dp; int count; cin >> count; stair = vector(count, 0); dp = vector(count, 0); for (int i = 0; i > stair[i]; } dp[0] = stair[0]; dp[1] = stair[0] + stair[1]; dp[2] = max(stair[0] + stair[2], stair[1] + stair[2]); for (int i = 3; i  풀이1. 계단의 정보를 저장하고 직접 최대값이 나올 수 있는 방법을 찾아본다.2. 직접 찾는 방법으로 dp를 만든다.dp0 = arr0dp1 = arr0 + arr1dp2 ..

    [C++] 프로그래머스 요격시스템

    [C++] 프로그래머스 요격시스템

    #include #include #include using namespace std; bool sortCompare(vector a, vector b) { return a[1] = end) { answer++; end = targets[i][1]; } } return answer; } 풀이 1. 끝지점이 작은순으로 정렬해준다. 2. 끝지점과 다음 시작점이 맞닿았다면 해당 끝지점으로 바꿔준..

반응형