結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-08 22:49:19 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,576 bytes |
| コンパイル時間 | 1,520 ms |
| コンパイル使用メモリ | 130,220 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-08 22:49:21 |
| 合計ジャッジ時間 | 2,001 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / 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));
};
if(!f(1) && !f(-1)) {
return 0;
}
const auto z = bins(INT32_MIN, INT32_MAX, f);
const int64_t nx = x - y * z, ny = y + x * z;
dump(z, nx, ny);
dump(a, std::hypotl(std::abs(nx - x), std::abs(ny - y)));
return std::round(a * std::hypotl(std::abs(nx - x), std::abs(ny - y)));
}
}
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';
}
}