結果
問題 | No.461 三角形はいくつ? |
ユーザー | Hoi_koro |
提出日時 | 2016-12-14 23:47:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 215 ms / 5,000 ms |
コード長 | 2,051 bytes |
コンパイル時間 | 1,307 ms |
コンパイル使用メモリ | 122,588 KB |
実行使用メモリ | 4,388 KB |
最終ジャッジ日時 | 2023-08-20 07:20:50 |
合計ジャッジ時間 | 6,846 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 191 ms
4,380 KB |
testcase_06 | AC | 98 ms
4,380 KB |
testcase_07 | AC | 121 ms
4,376 KB |
testcase_08 | AC | 80 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,384 KB |
testcase_10 | AC | 23 ms
4,380 KB |
testcase_11 | AC | 139 ms
4,380 KB |
testcase_12 | AC | 60 ms
4,376 KB |
testcase_13 | AC | 215 ms
4,376 KB |
testcase_14 | AC | 197 ms
4,380 KB |
testcase_15 | AC | 209 ms
4,380 KB |
testcase_16 | AC | 8 ms
4,376 KB |
testcase_17 | AC | 8 ms
4,380 KB |
testcase_18 | AC | 127 ms
4,376 KB |
testcase_19 | AC | 131 ms
4,380 KB |
testcase_20 | AC | 214 ms
4,380 KB |
testcase_21 | AC | 204 ms
4,380 KB |
testcase_22 | AC | 204 ms
4,376 KB |
testcase_23 | AC | 24 ms
4,384 KB |
testcase_24 | AC | 22 ms
4,376 KB |
testcase_25 | AC | 72 ms
4,380 KB |
testcase_26 | AC | 72 ms
4,380 KB |
testcase_27 | AC | 4 ms
4,384 KB |
testcase_28 | AC | 4 ms
4,380 KB |
testcase_29 | AC | 193 ms
4,380 KB |
testcase_30 | AC | 183 ms
4,376 KB |
testcase_31 | AC | 194 ms
4,380 KB |
testcase_32 | AC | 196 ms
4,380 KB |
testcase_33 | AC | 4 ms
4,376 KB |
testcase_34 | AC | 3 ms
4,380 KB |
testcase_35 | AC | 4 ms
4,380 KB |
testcase_36 | AC | 43 ms
4,380 KB |
testcase_37 | AC | 36 ms
4,380 KB |
testcase_38 | AC | 39 ms
4,380 KB |
testcase_39 | AC | 34 ms
4,380 KB |
testcase_40 | AC | 41 ms
4,376 KB |
testcase_41 | AC | 41 ms
4,376 KB |
testcase_42 | AC | 131 ms
4,380 KB |
testcase_43 | AC | 131 ms
4,388 KB |
testcase_44 | AC | 135 ms
4,376 KB |
ソースコード
#include <iostream> #include <sstream> #include <iomanip> #include <cstdio> #include <cassert> #include <algorithm> #include <iterator> #include <string> #include <vector> #include <list> #include <deque> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <tuple> #include <queue> #include <stack> #include <functional> #include <utility> #include <complex> #include <bitset> #include <numeric> #include <random> using namespace std; #define REP(i,n) for(int (i)=0; (i)<(n) ;++(i)) #define REPN(i,a,n) FOR((i),(a),(a)+(n)) #define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i)) #define PB push_back #define MP make_pair #define SE second #define FI first #define DBG(a) cerr<<(a)<<endl; #define dump(a) cerr<<#a <<' '<< a <<endl; #define ALL(v) (v).begin(),(v).end() typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL; typedef pair<int,int>PI; typedef vector<int> VI; const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7; PLL add(PLL a, PLL b){ LL den=a.SE*b.SE; LL num=a.FI*b.SE+a.SE*b.FI; return MP(num,den); } bool comp(PLL a, PLL b){ return a.FI*b.SE<a.SE*b.FI; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<vector<PLL>> l(3); vector<PLL> sum,mi; REP(i,n){ LL a,b,c; cin >> a >>b >> c; LL g=__gcd(b,c); l[a].emplace_back(b/g,(b+c)/g); } REP(i,3)l[i].emplace_back(1,1); sort(ALL(l[2]),comp); LL ans=0; REP(i,l[0].size()){ REP(j,l[1].size()){ PLL t=add(l[0][i],l[1][j]); if(t.SE>t.FI) continue; assert(t.SE>0); assert(t.FI>0); PLL mi=comp(l[0][i],l[1][j])?l[0][i]:l[1][j]; LL point=upper_bound(ALL(l[2]),MP(2*t.SE-t.FI,t.SE),comp)-lower_bound(ALL(l[2]),MP(2*t.SE-t.FI,t.SE),comp); LL outside=lower_bound(ALL(l[2]),MP(mi.SE-mi.FI,mi.SE),comp)-l[2].begin(); ans+=l[2].size()-point-outside; } } cout << ans <<endl; return 0; }