結果
問題 | No.461 三角形はいくつ? |
ユーザー |
![]() |
提出日時 | 2019-12-07 18:35:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 1,760 bytes |
コンパイル時間 | 1,143 ms |
コンパイル使用メモリ | 116,908 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 02:32:44 |
合計ジャッジ時間 | 4,646 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
#include <cstdio>#include <cstring>#include <iostream>#include <string>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <complex>#include <unordered_map>#include <unordered_set>#include <random>#include <cassert>#include <fstream>#include <utility>#include <functional>#include <time.h>#include <stack>#include <array>#define popcount __builtin_popcountusing namespace std;typedef long long int ll;typedef pair<ll, ll> P;struct R{ll x, y;R(ll x, ll y):x(x), y(y){}R(ll x):x(x), y(1ll){}R operator+(const R a) const{return R(x*a.y+y*a.x, y*a.y);}R operator-(const R a) const{return R(x*a.y-y*a.x, y*a.y);}bool operator==(const R a) const{return x*a.y==y*a.x;}bool operator<(const R a) const{return x*a.y<y*a.x;}bool operator>=(const R a) const{return x*a.y>=y*a.x;}};int main(){int n;cin>>n;vector<R> v[3];for(int i=0; i<n; i++){int p; ll a, b;cin>>p>>a>>b;v[p].push_back(R(a, a+b));}for(int i=0; i<3; i++){v[i].push_back(R(1));sort(v[i].begin(), v[i].end());}ll ans=0;for(int i=0; i<v[0].size(); i++){for(int j=0; j<v[1].size(); j++){R x=v[0][i], y=v[1][j];if(x+y<R(1)) continue;R z=max(R(1)-x, R(1)-y);int k=lower_bound(v[2].begin(), v[2].end(), z)-v[2].begin();ans+=(int)v[2].size()-k;k=lower_bound(v[2].begin(), v[2].end(), R(2)-x-y)-v[2].begin();if(k<v[2].size() && v[2][k]==R(2)-x-y && x+v[2][k]>=R(1) && y+v[2][k]>=R(1)) ans--;}}cout<<ans<<endl;return 0;}