C++

알고리즘 문제 풀이/1DP_과제(~180615)

180424_1032_베스트셀러

//https://www.acmicpc.net/problem/1032 #include #include #include #include using namespace std; struct book{ int idx; int cnt; string title; book(); book(int idx, string title, int cnt) : idx(idx), title(title), cnt(cnt) {}}; bool cmp(book a, book b){ if(a.cnt != b.cnt) return a.cnt> b.cnt; else { if(a.title.compare(b.title) < 0) return true; //사전 순으로 a가 b의 앞일 때 else return false; }}int main(){ ..

알고리즘 문제 풀이/1DP_과제(~180615)

180424_1068_트리

//https://www.acmicpc.net/problem/1068 #include #include using namespace std; int tree[50][50];//tree[i][0] : i 번째 노드의 자식 수 //tree[i][j] : i번째 노드의 자식 indexint n, d, ans;void search(int tmp);int main(){ cin >> n; int root; for(int i=0; i> p; if(p==-1) root=i; else{ tree[p][0]++; tree[p][tree[p][0]]=i; } } cin >> d; if(root==d) { cout

알고리즘 문제 풀이/1DP_과제(~180615)

180418_15683_감시

//https://www.acmicpc.net/problem/15683 #include using namespace std; int n, m, tv, mn;int map[8][8];int tvpos[8][3];void input();void dfs(int idx);void update();int main(){ input(); int num=4; if(map[tvpos[0][0]][tvpos[0][1]]==2) num=2; else if(map[tvpos[0][0]][tvpos[0][1]]==5) num=1; mn=64; for(int i=0; i n >> m; for(int i=0; i map[i][j]; if(0

알고리즘 문제 풀이/1DP_과제(~180615)

171025_2096_내려가기

#include using namespace std;int max(int a, int b){return a > b ? a : b;}int max(int a, int b, int c){return max(a, b) > c ? max(a, b) : c;}int min(int a, int b){return a > N;int max_arr[2][3] = { 0 };int min_arr[2][3] = { 0 };int input[3] = { 0 }; for (int i = 1; i > input[0] >> input[1] >> in..

bong sue
'C++' 태그의 글 목록