結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-08 22:58:49 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,717 bytes |
| コンパイル時間 | 1,511 ms |
| コンパイル使用メモリ | 128,644 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 22:58:56 |
| 合計ジャッジ時間 | 2,039 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 6 |
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#ifdef local
#include "debug_print.hpp"
#else
#define dump(...) void(0);
#endif
#include <iostream>
#include <ranges>
#include <iomanip>
#include <cstdint>
#include <cmath>
namespace man {
constexpr inline bool scope(const int l, const int x, const int r) noexcept { return l <= x && x <= r; }
constexpr inline int64_t bins(int64_t ok, int64_t ng, const auto &f) noexcept {
while(std::abs(ok - ng) > 1) {
const auto x = (ok + ng) / 2;
if(f(x)) {
ok = x;
} else {
ng = x;
}
}
return ok;
}
inline int64_t solve() noexcept {
int d;
int64_t x, y;
std::cin >> d >> x >> y;
const auto a = std::hypotl(x, y);
const auto f = [&](const int64_t z) -> bool {
const int64_t nx = x - y * z, ny = y + x * z;
return scope(0, nx, d) && scope(0, ny, d);
};
const int64_t z = bins(1, INT32_MAX, f), w = bins(-1, INT32_MIN, f);
const int64_t nx = x - y * z, ny = y + x * z;
const int64_t mx = x - y * w, my = y + x * w;
dump(z, nx, ny);
dump(w, mx, my);
if(scope(0, nx, d) && scope(0, ny, d)) {
return std::round(a * std::hypotl(nx - x, ny - y));
} else if(scope(0, mx, d) && scope(0, my, d)) {
return std::round(a * std::hypotl(mx - x, my - y));
}
return 0;
}
}
int main() {
std::cin.tie(nullptr) -> sync_with_stdio(false);
int t;
std::cin >> t;
std::cout << std::fixed << std::setprecision(12);
for([[maybe_unused]] const auto _: std::views::iota(0, t)) {
std::cout << man::solve() << '\n';
}
}