본문 바로가기

알고리즘73

백준 1764번 : 듣보잡 문제 링크 : www.acmicpc.net/problem/1764 풀이에 참고한 링크 : zerobell.tistory.com/9 blockdmask.tistory.com/178 내 풀이 (2020.12.21.) : #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); vector not_heard; vector not_seen; int N, M; cin >> N >> M; for (int i = 0; i > str; not_heard.push_back(str); } for (int i = 0; i < M; i+.. 2020. 12. 21.
백준 1874번 : 스택 수열 문제 링크 : www.acmicpc.net/problem/1874 풀이에 참고한 링크 : www.acmicpc.net/board/view/52749 내 풀이 (2020.12.18.) : #include #include #include using namespace std; int main() { stack stack; int n; cin >> n; vector target_list; int target_index = 0; for (int i = 0; i > num; target_list.push_back(num); } int input = 1; int max_num = 0; vector answer_list; bool flag = false; while (ta.. 2020. 12. 18.
백준 10845번 : 큐 문제 링크 : www.acmicpc.net/problem/10845 내 풀이 (2020.12.17.) : #include #include using namespace std; class Queue { deque queue; public: void push(int num) { this->queue.push_back(num); } void pop() { if (queue.size() == 0) { cout 2020. 12. 17.
백준 1074번 : Z 문제 링크 : www.acmicpc.net/problem/1074 풀이에 참고한 링크 : www.acmicpc.net/board/view/46542 내 풀이 (2020.12.17.) : #include #include using namespace std; int N, R, C; int cnt = 0; void search(int N, int r, int c) { if (N == 0) { if(R == r && C == c){ cout > N >> R >> C; search(N, 0, 0); } 결과 : 시간 초과 이 풀이의 시간복잡도는 O(2^2N)인데 N이 최대 15이므로 최대 걸리는 시간은 2^30 = 10,0000,0000 (10초) 이다. 내 풀이2 (2020.12.17.) : #include #.. 2020. 12. 17.