본문 바로가기

전체 글412

여러가지 종교 더블릿 12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include #include using namespace std; int root[200000] = { 0 }; int find(int x) { if (root[x] == x) return x; else return root[x] = find(root[x]);} void unify(int a, int b) { a = find(a); b = find(b); if (a > b) swap(a, b); root[b] = a;} int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i 2019. 2. 27.
(복습 필요) orders 더블릿 12345678910111213141516171819202122232425262728293031323334#include #include using namespace std; char input[205] = { 0 };char output[205] = { 0 };char alpha[30] = { 0 };int len; void dfs(int depth) { if (depth == len) { printf("%s\n", output); } for (int i = 0; i 0) { alpha[i]--; output[depth] = (char)(i + 'a'); dfs(depth + 1); alpha[i]++; } }} int main() { scanf("%s", input); len = strlen(inpu.. 2019. 2. 26.
말과 기사 더블릿 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816.. 2019. 2. 25.
댐 더블릿 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#include #include #include using namespace std; int arr[105][105] = { 0 };queue que; int main() { int n; scanf("%d", &n); for (int i = 1; i 2019. 2. 23.
(미해결) buy lower 더블릿 #include #include #include using namespace std; int dp[5005] = { 0 };int arr[5005] = { 0 };vector par(5005);int sum = 0, tmp = 1,maxDp=0; void findPar(int x,int tmp, int time) {if (time == maxDp) {sum += tmp;return;}for (int i = 0; i < par[x].size(); i++)findPar(par[x][i],tmp,time+1);} int main() {int n;scanf("%d", &n); for (int i = 1; i arr[i] && dp[j] == maxNum) {par[i].push_back(j);}}}for (in.. 2019. 2. 23.
색종이 더블릿 (업시퀀스) 12345678910111213141516171819202122232425262728293031323334353637383940414243#include #include #include #include using namespace std;vector arr(10005);int dp[10005] = { 0 }; bool compare(const pair& a, const pair& b) { if (a.first == b.first) return a.second 2019. 2. 21.
블록쌓기 더블릿 (업시퀀스) 2019. 2. 21.
줄 세우기 더블릿 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#include #include using namespace std; int arr[300] = { 0 };int dp[300] = { 0 };int par[300] = { 0 };int tmp = 0; void findPar(int x) { if (x == 0) return; tmp++; findPar(par[x]);} int main() { int n; scanf("%d", &n); for (int i = 1; i 2019. 2. 21.
up sequence 더블릿 (LIS) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include #include using namespace std; int arr[10005] = { 0 };int dp[10005] = { 0 };int par[10005] = { 0 }; void printPar(int x) { if (x == 0) return; printPar(par[x]); printf("%d ", arr[x]);} int main() { int n; scanf("%d", &n); for (int i = 1; i 2019. 2. 20.
미팅 수 최대 더블릿 1234567891011121314151617181920212223242526272829303132#include #include using namespace std; int dp[1005] = { 0 }; int main() { int n; scanf("%d", &n); int start, end; scanf("%d %d", &start, &end); for (int i = 0; i 2019. 2. 20.
테이블 옮기기 더블릿 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include #include #include #include #include #include using namespace std;vector table(300);priority_queue pq; bool compare(const pair& a, const pair& b) { if (a.first == b.first) return a.second 2019. 2. 20.
마감시간을 가지는 작업 더블릿 #include #include #include #include #include using namespace std;vector arr(20000);bool compare(const pair& a, const pair& b) {if (a.first == b.first)return a.second > b.second;return a.first > b.first;}int main() {int t, m, idx = 1;while (scanf("%d %d", &t, &m) != EOF) {arr[idx].first = t;arr[idx].second = m;idx++;}sort(&arr[1], &arr[idx], compare);int time = 0, rst = 0, end = arr[1].first;for .. 2019. 2. 20.