結果
問題 | No.947 ABC包囲網 |
ユーザー | ianCK |
提出日時 | 2020-09-26 17:08:52 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,857 bytes |
コンパイル時間 | 1,805 ms |
コンパイル使用メモリ | 50,380 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-29 05:08:57 |
合計ジャッジ時間 | 47,402 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | AC | 6 ms
5,376 KB |
testcase_19 | AC | 7 ms
5,376 KB |
testcase_20 | AC | 7 ms
5,376 KB |
testcase_21 | AC | 7 ms
5,376 KB |
testcase_22 | AC | 7 ms
5,376 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 1,697 ms
5,376 KB |
testcase_29 | AC | 1,973 ms
5,376 KB |
testcase_30 | WA | - |
testcase_31 | AC | 1,969 ms
5,376 KB |
testcase_32 | AC | 1,966 ms
5,376 KB |
testcase_33 | AC | 1,946 ms
5,376 KB |
testcase_34 | AC | 1,958 ms
5,376 KB |
testcase_35 | AC | 1,955 ms
5,376 KB |
testcase_36 | AC | 1,969 ms
5,376 KB |
testcase_37 | AC | 1,973 ms
5,376 KB |
testcase_38 | AC | 1,947 ms
5,376 KB |
testcase_39 | AC | 1,971 ms
6,944 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 1,935 ms
5,376 KB |
testcase_50 | WA | - |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 7 ms
5,376 KB |
testcase_58 | AC | 8 ms
5,376 KB |
testcase_59 | AC | 7 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:76:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 76 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp: In member function ‘void Point::in()’: main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%lf%lf", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#pragma GCC optimize("O3") #include <stdio.h> #include <algorithm> #include <vector> using namespace std; constexpr double kEps = 1E-10; constexpr int kN = int(4E3 + 10), kInf = int(1E9 + 10); #define PB push_back struct Point { double x, y; Point(double a, double b) {x = a, y = b;} Point() {} void in() { scanf("%lf%lf", &x, &y); return ; } inline Point operator -(Point b) const {return Point(x - b.x, y - b.y);} inline Point operator /(double b) const {return Point(x / b, y / b);} inline double operator *(Point b) const {return x * b.x + y * b.y;} inline double operator ^(Point b) const {return x * b.y - y * b.x;} }; struct Line { double a, b, c; Line(Point pa, Point pb) :a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb){} }; const Point O(0, 0); inline Point line_intersection(Line l1, Line l2) { return Point(-l1.b * l2.c + l1.c * l2.b, l1.a * l2.c - l1.c * l2.a) / (-l1.a * l2.b + l1.b * l2.a); } inline bool onsegment(Point p, Point a, Point b) { return ((a - p) * (b - p)) < kEps; } int n; Point p[kN]; bool cmp(int a, int b) {return (p[a] ^ p[b]) >= kEps;} int cnt(int x) { vector<int> left, right; int lpos = 0, rpos = 0, lsz, rsz, ans = 0; Line l(p[x], O); double tmp; for (int i = 1; i <= n; i++) if (i != x) { tmp = p[i] ^ p[x]; if (tmp < -kEps) left.PB(i); else if (tmp > kEps) right.PB(i); } sort(left.begin(), left.end(), cmp); sort(right.begin(), right.end(), cmp); lsz = int(left.size()); rsz = int(right.size()); while (lpos < lsz) { while (rpos < rsz) { if (onsegment(O, line_intersection(l, Line(p[left[lpos]], p[right[rpos]])), p[x])) rpos++; else break; } ans += rpos; lpos++; } return ans; } int main() { long long int ans = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) p[i].in(); for (int i = 1; i <= n; i++) ans += cnt(i); printf("%lld\n", ans / 3); }