結果
| 問題 | No.461 三角形はいくつ? |
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2016-12-12 02:20:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,016 bytes |
| 記録 | |
| コンパイル時間 | 964 ms |
| コンパイル使用メモリ | 52,176 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-29 12:41:42 |
| 合計ジャッジ時間 | 6,147 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 3 WA * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
47 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:48:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
48 | inc(i, n) { scanf("%d%d%d", &p[i], &a[i], &b[i]); }
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>
typedef long long signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(int i = (l) ; i < (r); i++)
#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
// ---- ----
int n, p[4000], a[4000], b[4000];
LL ans;
typedef std::pair<int, int> PII;
std::vector<PII> vec[3];
bool comp(PII x, PII y) {
return (x.first * y.second < y.first * x.second);
}
double val(PII x) { return static_cast<double>(x.first) / x.second; }
int main() {
scanf("%d", &n);
inc(i, n) { scanf("%d%d%d", &p[i], &a[i], &b[i]); }
inc(i, n) { vec[ p[i] ].push_back(std::make_pair(a[i], a[i] + b[i])); }
inc(i, 3) { vec[ i ].push_back(std::make_pair(1, 1)); }
inc(i, 3) { std::sort(vec[i].begin(), vec[i].end(), &comp); }
/*
inc(i, 3) {
for(auto && e: vec[i]) { printf("%2d/%2d = %.2f\n", e.first, e.second, static_cast<double>(e.first) / e.second); }
printf("\n");
}
*/
for(auto && e1: vec[1]) {
for(auto && e2: vec[2]) {
// printf("e1: <%2d,%4d>, e2: <%2d,%4d>, ", e1.first, e1.second, e2.first, e2.second);
PII x, y, z;
x = std::make_pair(e1.second - e1.first, e1.second);
y = std::make_pair(e2.second - e2.first, e2.second);
z = std::make_pair((e1.second - e1.first) * e2.second + (e2.second - e2.first) * e1.second, e1.second * e2.second);
if(comp(std::make_pair(1, 1), z)) { continue; }
if(comp(y, x)) { swap(x, y); }
auto lby = std::lower_bound(vec[0].begin(), vec[0].end(), y, &comp);
auto lbz = std::lower_bound(vec[0].begin(), vec[0].end(), z, &comp);
ans += (vec[0].end() - lby) - (lbz != vec[0].end() && (*lbz) == z);
/*
// printf("x: <%2d,%2d>, y: <%2d,%2d>, z: <%2d,%2d>, ", x.first, x.second, y.first, y.second, z.first, z.second );
printf("x: [%.2f], y: [%.2f], z: [%.2f], ", val(x), val(y), val(z) );
printf("ans += %d - %d\n", (vec[0].end() - lby), (lbz != vec[0].end() && (*lbz) == z) );
*/
}
}
printf("%lld\n", ans);
return 0;
}
FF256grhy