백준 문제/기하학

[백준] 11758번 CCW

dubu0721 2025. 3. 3. 21:01

문제: 11758번: CCW

 

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    vector<pair<int, int>> lines(3);
    for (int i = 0; i < 3; i++) {
        int x, y;
        cin >> x >> y;
        lines[i] = { x, y };
    }

    pair<int, int> a = { lines[1].first - lines[0].first, lines[1].second - lines[0].second };
    pair<int, int> b = { lines[2].first - lines[1].first, lines[2].second - lines[1].second };
    int c = { a.first * b.second - a.second * b.first };

    if (c < 0) {
        cout << -1 << "\n";
    }
    else if (c > 0) {
        cout << 1 << "\n";
    }
    else {
        cout << 0 << "\n";
    }

    return 0;
}

 

선형대수 수업때 배웠던 외적의 개념을 알고 있으면 해결할 수 있는 문제였다.