結果
問題 | No.461 三角形はいくつ? |
ユーザー | tubo28 |
提出日時 | 2016-12-12 17:45:34 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,395 bytes |
コンパイル時間 | 1,799 ms |
コンパイル使用メモリ | 177,312 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-14 13:24:45 |
合計ジャッジ時間 | 52,562 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 7 ms
6,820 KB |
testcase_05 | AC | 1,744 ms
6,820 KB |
testcase_06 | AC | 1,029 ms
6,820 KB |
testcase_07 | AC | 1,186 ms
6,816 KB |
testcase_08 | AC | 814 ms
6,816 KB |
testcase_09 | AC | 5 ms
6,820 KB |
testcase_10 | AC | 256 ms
6,820 KB |
testcase_11 | AC | 1,443 ms
6,816 KB |
testcase_12 | AC | 620 ms
6,816 KB |
testcase_13 | AC | 2,088 ms
6,816 KB |
testcase_14 | AC | 2,137 ms
6,820 KB |
testcase_15 | AC | 2,073 ms
6,816 KB |
testcase_16 | AC | 1,337 ms
6,816 KB |
testcase_17 | AC | 1,323 ms
6,816 KB |
testcase_18 | AC | 2,458 ms
6,816 KB |
testcase_19 | AC | 2,348 ms
6,820 KB |
testcase_20 | AC | 2,026 ms
6,820 KB |
testcase_21 | AC | 2,161 ms
6,820 KB |
testcase_22 | AC | 2,132 ms
6,816 KB |
testcase_23 | AC | 1,050 ms
6,816 KB |
testcase_24 | AC | 983 ms
6,816 KB |
testcase_25 | AC | 7 ms
6,820 KB |
testcase_26 | AC | 6 ms
6,820 KB |
testcase_27 | TLE | - |
testcase_28 | AC | 7 ms
6,820 KB |
testcase_29 | AC | 498 ms
6,824 KB |
testcase_30 | AC | 232 ms
6,816 KB |
testcase_31 | AC | 984 ms
6,816 KB |
testcase_32 | AC | 1,271 ms
6,816 KB |
testcase_33 | AC | 6 ms
6,816 KB |
testcase_34 | AC | 7 ms
6,816 KB |
testcase_35 | AC | 7 ms
6,816 KB |
testcase_36 | AC | 1,105 ms
6,816 KB |
testcase_37 | AC | 1,171 ms
6,816 KB |
testcase_38 | AC | 1,175 ms
6,816 KB |
testcase_39 | AC | 1,213 ms
6,816 KB |
testcase_40 | AC | 1,183 ms
6,816 KB |
testcase_41 | AC | 1,154 ms
6,820 KB |
testcase_42 | AC | 1,434 ms
6,816 KB |
testcase_43 | AC | 1,403 ms
6,816 KB |
testcase_44 | AC | 1,480 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(c) begin(c), end(c) #define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl typedef long long Integer; inline Integer gcd(Integer a, Integer b) { return a > 0 ? gcd(b % a, a) : b; } struct rational { Integer p, q; void normalize() { // keep q positive if (q < 0) p *= -1, q *= -1; Integer d = gcd(p < 0 ? -p : p, q); if (d == 0) p = 0, q = 1; else p /= d, q /= d; } rational(Integer p, Integer q = 1) : p(p), q(q) { normalize(); } rational &operator += (const rational &a) { p = a.q * p + a.p * q; q = a.q * q; normalize(); return *this; } rational &operator -= (const rational &a) { p = a.q * p - a.p * q; q = a.q * q; normalize(); return *this; } rational &operator *= (const rational &a) { p *= a.p; q *= a.q; normalize(); return *this; } rational &operator /= (const rational &a) { p *= a.q; q *= a.p; normalize(); return *this; } rational &operator - () { p *= -1; return *this; } }; inline rational operator + (const rational &a, const rational &b) { return rational(a) += b; } inline rational operator * (const rational &a, const rational &b) { return rational(a) *= b; } inline rational operator - (const rational &a, const rational &b) { return rational(a) -= b; } inline rational operator / (const rational &a, const rational &b) { return rational(a) /= b; } inline bool operator < (const rational &a, const rational &b) { // avoid overflow // return (long double)a.p * b.q < (long double)a.q * b.p; return a.p * b.q < a.q * b.p; } inline bool operator <= (const rational &a, const rational &b) { return !(b < a); } inline bool operator > (const rational &a, const rational &b) { return b < a; } inline bool operator >= (const rational &a, const rational &b) { return !(a < b); } inline bool operator == (const rational &a, const rational &b) { return a.p == b.p && a.q == b.q; } inline bool operator != (const rational &a, const rational &b) { return !(a == b); } int n; vector<rational> ls[3]; int main() { while (cin >> n) { for (int i = 0; i < 3; ++i) ls[i].clear(); rep(i, n) { int p; int a, b; cin >> p >> a >> b; ls[p].emplace_back(a, a + b); } for (int i = 0; i < 3; ++i) sort(all(ls[i])); // 1本 ll ans = n + 1; for (auto &x : ls[1]) { x = 1 - x; ans += ls[0].end() - upper_bound(all(ls[0]), x); } for (auto &y : ls[2]) { y = 1 - y; ans += ls[0].end() - upper_bound(all(ls[0]), y); } for (auto &x : ls[1]) { for (auto &y : ls[2]) { if (x + y < 1) { // 2本 (1,2) ++ans; } if (x + y <= 1) { // 3本 (0,1,2) int a = lower_bound(all(ls[0]), x + y) - lower_bound(all(ls[0]), max(x, y)); int b = ls[0].end() - upper_bound(all(ls[0]), x + y); ans += a + b; } } } cout << ans << endl; } }