https://www.acmicpc.net/problem/11758
11758번: CCW
첫째 줄에 P1의 (x1, y1), 둘째 줄에 P2의 (x2, y2), 셋째 줄에 P3의 (x3, y3)가 주어진다. (-10,000 ≤ x1, y1, x2, y2, x3, y3 ≤ 10,000) 모든 좌표는 정수이다. P1, P2, P3의 좌표는 서로 다르다.
www.acmicpc.net
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
int p2p1x = x1 - x2;
int p2p1y = y1 - y2;
int p2p3x = x3 - x2;
int p2p3y = y3 - y2;
int ccw = p2p1x * p2p3y - p2p1y * p2p3x;
if (ccw > 0) cout << -1; //벡터의 외적값이 0보다 크면 시계방향
else if (ccw < 0) cout << 1; //작으면 반시계방향
else cout << 0; //0이면 일직선
}
2162번: 선분 그룹 - CCW, 유니온 파인드 (0) | 2023.01.23 |
---|---|
20149번: 선분 교차 3 - CCW (0) | 2023.01.23 |
1005번: ACM Craft - 다익스트라, 위상 정렬 (0) | 2023.01.23 |
17472번: 다리 만들기 2 - 최소 스패닝 트리(MST) (0) | 2023.01.23 |
2042번: 구간 합 구하기 - 세그먼트 트리(Segment Tree) (0) | 2023.01.21 |
댓글 영역