#include <bits/stdc++.h>
using namespace std;
int product(int x1, int y1, int x2, int y2) { return x1 * y2 - x2 * y1; }
int vproduct(pair<int, int> &a, pair<int, int> &b) {
return product(a.first, a.second, b.first, b.second);
}
pair<int, int> vec(pair<int, int> &a, pair<int, int> &b) {
auto [x1, y1] = a;
auto [x2, y2] = b;
return {x2 - x1, y2 - y1};
}
int main() {
int n;
cin >> n;
vector<pair<int, int>> portals(n);
int x, y;
for (auto &p : portals) {
cin >> x >> y;
p = {x, y};
}
auto v1 = vec(portals[0], portals[1]);
auto v2 = vec(portals[0], portals[2]);
auto a = abs(vproduct(v1, v2));
cout << (a ? a : -1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
38 ms |
2612 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |