結果
| 問題 |
No.3042 拡大コピー
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-03-01 18:00:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 292 ms / 2,000 ms |
| コード長 | 2,105 bytes |
| コンパイル時間 | 465 ms |
| コンパイル使用メモリ | 58,232 KB |
| 実行使用メモリ | 11,940 KB |
| 最終ジャッジ日時 | 2025-03-01 18:00:19 |
| 合計ジャッジ時間 | 2,693 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘void readpts(int, pt*)’:
main.cpp:61:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%lf%lf", &ps[i].x, &ps[i].y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:78:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
78 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3042.cc: No.3042 諡。螟ァ繧ウ繝斐・ - yukicoder
*/
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1000000;
/* typedef */
template <typename T>
struct Pt {
T x, y;
Pt() {}
Pt(T _x, T _y) : x(_x), y(_y) {}
Pt(const Pt<T> &p) : x(p.x), y(p.y) {}
Pt<T> operator+(const Pt<T> p) const { return Pt<T>(x + p.x, y + p.y); }
Pt<T> operator-() const { return Pt<T>(-x, -y); }
Pt<T> operator-(const Pt<T> p) const { return Pt<T>(x - p.x, y - p.y); }
Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
T dot(Pt<T> v) const { return x * v.x + y * v.y; }
T cross(Pt<T> v) const { return x * v.y - y * v.x; }
Pt<T> mid(const Pt<T> p) { return Pt<T>((x + p.x) / 2, (y + p.y) / 2); }
T d2() { return x * x + y * y; }
double d() { return sqrt(d2()); }
Pt<T> rot(double th) {
double c = cos(th), s = sin(th);
return Pt<T>(c * x - s * y, s * x + c * y);
}
Pt<T> rot90() { return Pt<T>(-y, x); }
bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
bool operator<(const Pt<T> &pt) const {
return x < pt.x || (x == pt.x && y < pt.y);
}
void print() { printf("(%d,%d)", x, y); }
};
using pt = Pt<double>;
/* global variables */
pt ps[MAX_N], qs[MAX_N];
/* subroutines */
void readpts(int n, pt ps[]) {
for (int i = 0; i < n; i++)
scanf("%lf%lf", &ps[i].x, &ps[i].y);
}
int farthest(int n, pt ps[], int st) {
double maxd2 = -1, maxi = -1;
for (int i = 0; i < n; i++)
if (i != st) {
double d2 = (ps[i] - ps[st]).d2();
if (maxd2 < d2) maxd2 = d2, maxi = i;
}
return maxi;
}
/* main */
int main() {
int n;
scanf("%d", &n);
readpts(n, ps);
readpts(n, qs);
int p0 = farthest(n, ps, 0);
int p1 = farthest(n, ps, p0);
int q0 = farthest(n, qs, 0);
int q1 = farthest(n, qs, p0);
double pd = (ps[p1] - ps[p0]).d2();
double qd = (qs[q1] - qs[q0]).d2();
double r = sqrt(qd / pd);
printf("%.10lf\n", r);
return 0;
}
tnakao0123