結果
| 問題 |
No.461 三角形はいくつ?
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-07-26 21:18:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 177 ms / 5,000 ms |
| コード長 | 950 bytes |
| コンパイル時間 | 1,707 ms |
| コンパイル使用メモリ | 168,144 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-07-26 21:18:52 |
| 合計ジャッジ時間 | 5,724 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d%d%d",&p,&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=4005;
const long double eps=1e-17;
int n;
vector<long double> t[3];
ll ans;
int main(){
scanf("%d",&n);
t[0].push_back(1);t[1].push_back(1);t[2].push_back(1);
for(int i=1;i<=n;++i){
int p,a,b;
scanf("%d%d%d",&p,&a,&b);
t[p].push_back(a/(long double)(a+b));
}
sort(t[0].begin(),t[0].end());
sort(t[1].begin(),t[1].end());
sort(t[2].begin(),t[2].end());
for(long double l0:t[0]){
for(long double l1:t[1]){
long double mx=max(1-l0,1-l1);
long double jd=2-l0-l1;
if(jd>1+eps)continue;
int it1=lower_bound(t[2].begin(),t[2].end(),mx-eps)-t[2].begin();
int it2=lower_bound(t[2].begin(),t[2].end(),jd-eps)-t[2].begin();
ans+=t[2].size()-it1;
if(fabs(t[2][it2]-jd)<eps)ans--;
}
}
printf("%lld\n",ans);
return 0;
}
vjudge1