結果
問題 | No.947 ABC包囲網 |
ユーザー |
![]() |
提出日時 | 2019-12-10 23:29:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,446 bytes |
コンパイル時間 | 1,789 ms |
コンパイル使用メモリ | 173,948 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-06-24 02:39:51 |
合計ジャッジ時間 | 5,938 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 11 TLE * 1 -- * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; signed main() { int n; cin >> n; vector<P> xy; for (int i=0; i<n; i++) { int xi, yi; cin >> xi >> yi; xy.push_back(P(xi, yi)); } sort(xy.begin(), xy.end(), [](auto const& lhs, auto const& rhs){return lhs.first<rhs.first;}); int ans = 0; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { for (int k=j+1; k<n; k++) { int x1=xy[i].first, y1=xy[i].second; int x2=xy[j].first, y2=xy[j].second; int x3=xy[k].first, y3=xy[k].second; if (x1==x2 && x2==x3) { continue; } else if (x1==x2) { if ((x3*y1-y3*x1>0 && x3*y2-y3*x2<0) || (x3*y1-y3*x1<0 && x3*y2-y3*x2>0)) { ans++; } } else if (x2==x3) { if ((x2*y1-y2*x1>0 && x3*y1-y3*x1<0) || (x2*y1-y2*x1<0 && x3*y1-y3*x1>0)) { ans++; } } else { if ((x2*y1-y2*x1<0 && x3*y2-y3*x2<0 && x3*y1-y3*x1>0) || (x2*y1-y2*x1>0 && x3*y2-y3*x2>0 && x3*y1-y3*x1<0)) { ans++; } } } } } cout << ans << endl; }