WookjeBlog
    • 블로그
    • 소개
    • 태그
    • 수업/강의
    • 라이브러리
    Main
    • Share to Facebook

    큐

    All Posts in queue

    • [BOJ] 11000 : 강의실 배정

      11000 : 강의실 배정 풀이 일반적으로 스위핑 해서 풀면 (start == end)인 경우를 처리하기가 까다롭다. pq를 이용해서 풀어주자. 코드 #include <stdio.h> #include <queue> #include <algorithm> using namespace std; typedef pair<int, int> pii; int n; pii p[200002]; priority_queue<pii> pq; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d", &p[i].first, &p[i].second); } sort(p, p + n); for (int i = 0; i < n; i++) { int s =...

      boj greedy queue

      wookje.kwon's profile image

      wookje.kwon

      2018-02-14 22:15

    • [BOJ] 1966 : 프린터 큐

      1966 : 프린터 큐 풀이 프린터 터져욧!! 코드 #include </bits/stdc++.h> using namespace std; int main() { int tc; scanf("%d", &tc); while (tc--) { int n, m, cnt = 1; queue<pair<int, int> > qu; priority_queue<int> pq; scanf("%d %d", &n, &m); for (int i = 0, a; i < n; i++) { scanf("%d", &a); qu.push({ a,i }); pq.push(a); } while (!pq.empty()) { auto n1 = qu.front(); int n2 = pq.top(); if (n1.first == n2) { if (n1.second...

      boj queue naive

      wookje.kwon's profile image

      wookje.kwon

      2018-01-21 22:42

    • [BOJ] 1753 : 최단경로

      1753 : 최단경로 풀이 다익스트라를 짜자 우선순위 큐를 쓰자 코드 #include <stdio.h> #include <algorithm> #include <queue> #include <vector> using namespace std; const int v_ = 20000 + 1; const int INF = 987654321; struct edg { int idx, dst; edg() {} edg(int idx, int dst) : idx(idx), dst(dst) {} bool operator <(edg A)const { return dst > A.dst; } }; int v, e, s, dst[v_]; vector<edg> gph[v_]; void dijkstra() { for (int i = 0;...

      boj dijkstra queue

      wookje.kwon's profile image

      wookje.kwon

      2017-02-14 18:33

    • github
    • facebook
    • rss

    Copyright © Wookje Kwon. All rights reserved.