개발 일지
-
백준 1193번 c++ 풀이백준 2018. 11. 18. 19:30
수1의 군수열 열심히 풀때가 생각났읍니다. 근데 군수열 푸는게 더 쉬워.. #include #include #include #include using namespace std; int main(){ cin.tie(NULL); ios::sync_with_stdio(false); int n; cin >> n; int index = 1; int group = 1; int mother = 1; int son = 1; while (index != n){ if (group % 2 == 0){ if (mother == 1){ //끝 group++; son = group; }else { mother--; son++; } }else { if (son == 1){ group++; mother = group; }else {..
-
백준 16935번 C++ 풀이백준 2018. 11. 18. 18:37
#include #include #include #include using namespace std; long long dp[31][31]; long long func(int n, int k){ if (dp[n][k] != -1){ return dp[n][k]; } if (k == 1){ dp[n][k] = 1; return dp[n][k]; } if (n == k){ dp[n][k] = 1; return dp[n][k]; } dp[n][k] = func(n-1, k) + func(n-1, k-1); return dp[n][k]; } int main(){ cin.tie(NULL); ios::sync_with_stdio(false); for (auto i =0; i n >> k; cout
-
백준 16936번 C++ 풀이백준 2018. 11. 18. 18:25
벡터로 담아 정렬한 뒤에 하나씩 갱신합니다. #include #include #include #include using namespace std; int buffer[1001]; bool isVisited[1001]; int main(){ cin.tie(NULL); ios::sync_with_stdio(false); int n; cin >> n; vector v; for (auto i=0; i> x >> y; v.push_back(make_pair(min(x,y),max(x,y))); } sort(v.begin(), v.end()); long long totalLength = 0; // bool shouldThinkPrevious = false; for (auto i=1; i
-
백준 10451 C++ 풀이카테고리 없음 2018. 11. 18. 17:47
순열 사이클의 정의가 좀 모호해서 짜증났는데,적당히 엉성하게 플밍했더니 통과되었습니다. 무슨 정의를 예시로 해... 문제 별로에요. #include #include #include #include using namespace std; int buffer[1001]; bool isVisited[1001]; int main(){ cin.tie(NULL); ios::sync_with_stdio(false); int t; cin >> t; for(auto k=0; k> n; for (auto i=1; i> buffer[i]; } for (auto i=1; i
-
백준 1325번 C++ 풀이백준 2018. 11. 18. 17:08
최적화를 안 해서 메모리와 시간사용량이 대단합니다. #include #include #include #include using namespace std; vector buffer[10001]; bool isVisited[10001]; int maxHackable[10001]; int main(){ cin.tie(NULL); ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (auto i=0; i> a >> b; // a가 b를 신뢰한다 -> b 해킹시 a buffer[b].push_back(a); } priority_queue pq; for (auto i=1; i
-
백준 14890번 C++ 풀이백준 2018. 11. 17. 19:33
#include #include #include #include #include #include using namespace std; int n; int buffer[101][101]; int l; int main(){ cin.tie(NULL); ios::sync_with_stdio(false); cin >> n >> l; for (auto x=0; x buffer[x][y]; } } int count = 0; for (auto x=0; x= l){ v[i].second -= l; }else { goto Fail; } } } } count++; Fail:; } } for (auto y=0; y= l){ v[i].second -= l; }else { goto Fail_2; } } } } count++; F..