백준

    [골4] 4386 - 별자리 만들기

    #include #include #include #include #pragma region 빠른 입출력 #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #pragma endregion using namespace std; using dp = pair; #define MAX 101 #define x first #define y second vector star; vector coord; int parent[MAX]; double ans; int GetParent(int a) { return (parent[a] == a) ? a : parent[a] = GetParent(parent[a]); }..

    [골5] 2166 - 다각형의 면적

    #include #include #include #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ #define x first #define y second using namespace std; using dp = pair; double Calculate(double x1, double x2, double x3, double y1, double y2, double y3) { double res = x1 * y2 + x2 * y3 + x3 * y1; res -= x2 * y1 + x3 * y2 + x1 * y3; return res / 2; } int main() { FAST_IO(); int ..

    [골5] 2467 - 용액

    #include #include #include #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ using namespace std; int main() { FAST_IO(); int n; cin >> n ; vector v(n); for (int i = 0; i > v[i]; int s = 0, e = n - 1, min = 2e9; pair res; while (s < e) { int a = v[s], b = v[e]; int val = abs(a + b); if (val < min) { min = val; res = { a, b }; } if (a + b < ..

    [골5] 19951 - 태상이의 훈련소 생활

    #include #include #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ using namespace std; int n, m; int main() { FAST_IO(); cin >> n >> m; vector v(n + 1), s(n + 2); for (int i = 1; i > v[i]; // 입력 for (int i = 1; i > a >> b >> k; // 답 도출 s[a] += k; s[b + 1] -= k; } int sum = 0; for (int i = 1; i

    [골5] 24891 - 단어 마방진

    #include #include #include #include #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ using namespace std; vector ans(20), s(20); vector vis(20); int l, n; void DFS(int cnt = 0) { if (cnt == l) { bool flag = true; for (int i = 0; i < l; i++) { for (int j = i + 1; j < l; j++) { if (flag) flag = (ans[i][j] == ans[j][i]); } } if (flag) { for (int i = 0; i < ..

    [실3] 21921 - 블로그

    #include #define FAST_IO() \ {\ ios::sync_with_stdio(false);\ cin.tie(NULL); \ cout.tie(NULL); \ }\ using namespace std; int main() { FAST_IO(); int arr[250000]{0}; int n, x; cin >> n >> x; for (int i = 1; i > num; arr[i] = arr[i - 1] + num; } int ans = 0, cnt = 0; for (int i = x; i 0) cout

    [실4] 28279 - 덱2

    #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; deque dq; while(n--) { int o, t; cin >> o; if (o == 1) { cin >> t; dq.push_front(t); } else if (o == 2) { cin >> t; dq.push_back(t); } else if (o == 3) { if (dq.empty()) cout

    [실4] 10866 - 덱

    #include #include #include #include #include #include #include #include #include using namespace std; deque my_deque; vector my_vec; void Push_front(int _value) { my_deque.push_front(_value); } void Push_back(int _value) { my_deque.push_back(_value); } void Pop_front() { if (my_deque.empty()) { my_vec.push_back(-1); return; } my_vec.push_back(my_deque.front()); my_deque.pop_front(); } void Pop_b..

    [실3] 2346 - 풍선 터뜨리기

    #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; deque dq; for (int i = 0; i > t; dq.push_back({t, i + 1}); } while (!dq.empty()) { int t = dq.front().first; cout

    [실1] 1914 - 하노이 탑

    #include #include #include using namespace std; void Move(int c, int s, int m, int e) { if (c == 1) { cout