| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 구현
- vector
- 정석
- c++
- 컴공
- Stack
- Operating System
- 알고리즘
- coding
- 컴퓨터공학과
- 자료구조
- 정석학술정보관
- bfs
- OS
- 그래프
- 오퍼레이팅시스템
- cs
- Computer science
- 컴공과
- 문제풀이
- 코테
- 북리뷰
- 너비우선탐색
- 개발
- DP
- 브루트포스
- 코딩
- 백준
- 스택
- 오에스
- Today
- Total
목록map (7)
Little Jay
substring과 map을 활용한 문제 map은 자료를 저장할때 red-black tree 구조로 구현이 되어있기 때문에 자동 정렬이 된다. 이는 int형 뿐만 아니라 string 형태에서도 char에 따라서 정렬을 한다. 'ab' > n; v..
사실 내 힘으로 푼 문제는 아니다. 도저히 아이디어가 떠오르지 않아 다른 분들의 블로그를 참고했다. 식을 세우는데 어려움을 겪었는데 각 의상 종류별 + 1한 값의 곱에서 전체를 안입는 경우인 1을 빼주면 되는 식을 세우는 것이 결국 관건이었던 것 같다. 이거를 도출해낸다는게 쉽지 않았고 Silver 3문제였는데도 이 아이디어를 30분 넘게 고민하다가 안되서 결국 참고했다. #include #define endl '\n' using namespace std; int t, n; string name, cloth; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; map mp; f..
시험기간에 너무 공부가 안되서 푼 문제 KMP, Boyer-Moore, NP-Hard, NP-Complete 등등 너무 어렵다 정말 학교에서 알고리즘 과제하는데 string pattern matching 알고리즘이 너무 어려워서 string 관련 문제 하나 풀었다. 어렵지는 않은데 입력을 받을때 cin >> str을 하면 틀리고, getline(cin, str)을 해주면 맞았다 이건 또 왜 그런지 잘 모르겠다 백분율 구하는 문제라서 크게 어렵지는 않았던 문제 #include using namespace std; map m; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string str; float cnt = ..
map을 사용해서 간단히 풀 수 있는 문제 #include #define endl '\n' using namespace std; map d = { {"black", 0}, {"brown", 1}, {"red", 2}, {"orange", 3}, {"yellow", 4}, {"green", 5}, {"blue", 6}, {"violet", 7}, {"grey", 8}, {"white", 9}, }; string s1, s2, s3; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> s1 >> s2 >> s3; long long ans = d[s1] * 10 + d[s2]; for (int i = 0; i < d[s3]; i+..
map을 활용한 기본적인 문제 #include #include using namespace std; int n; map m; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; while (n--) { string s; cin >> s; ++(m[s]); } pair p; int max = 0; for (auto s : m) { if (s.second > max) { max = s.second; p = s; } } cout
간단한 이진탐색 문제 참 메모리라는게 아속하다 문제의 태그에는 set 혹은 map이 달려있어서 처음에는 당연히 set으로 풀었는데 시간초과가 발생해버렸다. 아무래도 set이나 map이나 기능적으로 이진트리의 모습을 만들어야하기 때문에 계속해서 sort해주는 부분에서 메모리를 많이 잡아먹은 것 같다. #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; for (int i = 0; i > n; vector v; for (int j = 0; j > temp; v..
map을 이용해서 풀면 간단히 해결할 수 있는 문제 linux 채점환경이기때문에 시간초과가 나지 않으려면 ios::sync_with_stdio(false); cin.tie(0); 를 추가해주어야 한다 #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; string site, pw; map mp; for (int i = 0; i > site >> pw; mp.insert(pair(site, pw)); } for (int i = 0; i > site; cout second