結果
問題 | No.94 圏外です。(EASY) |
ユーザー |
![]() |
提出日時 | 2014-12-07 19:47:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,663 ms / 5,000 ms |
コード長 | 1,110 bytes |
コンパイル時間 | 658 ms |
コンパイル使用メモリ | 65,884 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 07:21:15 |
合計ジャッジ時間 | 20,071 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:29:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | REP (i, N) scanf("%d%d", X+i, Y+i); | ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<iostream> #include<vector> #include<algorithm> #include<string> #include<cstring> #include<cmath> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0; i<int(n); i++) #define EACH(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++) template<class T> inline T &amin(T &a, T b) { if (a>b) a=b; return a; } template<class T> inline T &amax(T &a, T b) { if (a<b) a=b; return a; } int N, X[1111], Y[1111]; bool FW[1111][1111]; int sq(int x) { return x*x; } int sqsum(int i, int j) { return sq(X[i] - X[j]) + sq(Y[i] - Y[j]); } double hypot(int i, int j) { return sqrt(sqsum(i, j)); } int main() { scanf("%d", &N); REP (i, N) scanf("%d%d", X+i, Y+i); REP (i, N) REP (j, N) if (sqsum(i, j) <= 100) FW[i][j] = true; REP (k, N) REP (i, N) REP (j, N) FW[i][j] = FW[i][j] || (FW[i][k] && FW[k][j]); double ans = 1; REP (i, N) { REP (j, N) { if (FW[i][j]) { amax(ans, hypot(i, j) + 2.0); } } } printf("%.9f\n", ans); return 0; }