![[백준 C++] 11723 : 집합](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Feh6eK2%2FbtsK58xTXpO%2FYTKUChQ4yTjh7Qzlrkvlb1%2Fimg.png)
https://www.acmicpc.net/problem/11723시간초과에 주의하여 풀면 되는 간단한 문제이다.#include #include using namespace std;int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); set list; int M; cin >> M; for (int m = 0; m > str; if (str.compare("add") == 0) { int input; cin >> input; list.insert(input); } else if (str.compare("remove") == 0) { int input; cin >> input; list.erase(input);..
![[백준 C++] 10816 : 숫자 카드 2](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdXAoa3%2FbtsKS7Vmrrl%2FyKbJD2l1107ZJbDMSR5h00%2Fimg.png)
https://www.acmicpc.net/problem/10816주어지는 수의 범위가 굉장히 크기 때문에, 시간초과에 유의해서 풀어야 한다.#include #include #include using namespace std;int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int N, M; vector list; vector input; cin >> N; for (int i = 0; i > temp; list.push_back(temp); } sort(list.begin(), list.end()); cin >> M; for (int i = 0; i > temp; input.push_back(temp); } for (int i = ..
![[백준 C++] 1764 : 듣보잡](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FGTDER%2FbtsKTp7LKzn%2Fy1qw5LR03wUpZEdaoLNGKk%2Fimg.png)
https://www.acmicpc.net/problem/1764시간초과를 잘 처리해야 하는 문제이다.#include #include using namespace std;int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int N, M; set list; set ans; cin >> N >> M; for (int i = 0; i > temp; list.insert(temp); } for (int i = 0; i > temp; auto check = list.find(temp); if (check != list.end()) ans.insert(temp); } cout 시간초과를 방지하기 위해 tie와 sync_with_std..
![[백준 C++] 11866 : 요세푸스 문제 0](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FAN98j%2FbtsKOHveqPx%2FYOJCVGv1GeIlG19Uni72t0%2Fimg.png)
https://www.acmicpc.net/problem/11866solved.ac Class 2 에센셜에 포함되어 있는 구현 문제이다.#include #include using namespace std;int main(){ int list[1001] = { 0, }; int N, K; cin >> N >> K; int idx = K; vector ans; for (int i = 1; i = N) break; else { int move = 0; while (move N) idx = 1; else idx += 1; if (list[idx] != 0) move++; } } } cout \n"; return 0;}while문 안에 while문이 또 있어 ..