結果
問題 |
No.1144 Triangles
|
ユーザー |
![]() |
提出日時 | 2020-07-31 22:52:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,306 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 80,732 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 20:20:06 |
合計ジャッジ時間 | 5,913 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 12 RE * 1 |
コンパイルメッセージ
main.cpp: In lambda function: main.cpp:25:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 25 | auto [a, b] = p; | ^ main.cpp:26:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 26 | auto [c, d] = q; | ^
ソースコード
#include <algorithm> #include <vector> #include <numeric> #include <iostream> using namespace std; using P = pair<int, int>; long long cp(P p, P q) { return (long long)p.first * q.second - (long long)p.second * q.first; } P operator+(P p, P q) { return { p.first + q.first, p.second + q.second}; } P operator-(P p, P q) { return { p.first - q.first, p.second - q.second}; } const int M = 1000000007; int main() { int n; cin >> n; P p[n]; for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second; long long ans = 0; for (int i = 0; i < n; i++) { vector<P> q; for (int j = 0; j < n; j++) if (p[i] != p[j]) q.push_back(p[j] - p[i]); sort(q.begin(), q.end(), [](P p, P q) { auto [a, b] = p; auto [c, d] = q; if (b > 0) { if (d < 0) return true; else if (d == 0) return c < 0; else return cp(p, q) > 0; } else if (b == 0) { if (a > 0) return true; else return d < 0; } else { if (d >= 0) return false; else return cp(p, q) > 0; } }); // cerr << "center = " << p[i].first << " " << p[i].second << endl; // for (P x : q) cerr << "(" << x.first << ", " << x.second << "); "; cerr << endl; // while (it2 != q.end() && it2->second >= 0) it2++; // P S = {0, 0}, T = {0, 0}; // for (auto it = q.begin(); it != it2; it++) S = S + *it; // for (auto it = it2; it != q.end(); it++) T = T + *it; // if (it2 == q.end()) it2 = q.begin(); P S = {0, 0}; const int m = q.size(); for (int i = 0; i < m; i++) q.push_back(q[i]); for (int i = 0, j = 0; i < m; i++) { while (i == j || cp(q[i], q[j]) > 0) { S = S + q[j]; j++; } ans += cp(q[i], S); // cerr << "S = " << S.first << " " << S.second << endl; // cerr << "q[i] = " << q[i].first << " " << q[i].second << endl; // cerr << "area = " << cp(q[i], S) << endl; S = S - q[i]; } // cerr << ans % M << endl; } cout << ans % M * 333333336 % M << endl; }