結果
問題 |
No.94 圏外です。(EASY)
|
ユーザー |
|
提出日時 | 2015-06-25 20:24:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 51,648 KB |
最終ジャッジ日時 | 2024-11-14 19:05:31 |
合計ジャッジ時間 | 737 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:3: error: ‘vector’ was not declared in this scope 20 | vector<Point> v(n); | ^~~~~~ main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 2 | #include <algorithm> +++ |+#include <vector> 3 | using namespace std; main.cpp:20:15: error: expected primary-expression before ‘>’ token 20 | vector<Point> v(n); | ^ main.cpp:20:17: error: ‘v’ was not declared in this scope 20 | vector<Point> v(n); | ^ main.cpp:49:20: error: ‘sqrt’ was not declared in this scope 49 | printf("%lf\n", sqrt(res) + 1 + (n>0)); | ^~~~ main.cpp:19:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:22:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | int x, y; scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <iostream> #include <algorithm> using namespace std; class Point { public: int x, y; Point(void) {} Point(int _x, int _y) { x = _x; y = _y; } bool operator==(const Point& other) const { return x == other.x && y == other.y; } int distdist(const Point& other) const { return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y); } }; int cost[1010][1010]; bool route[1010][1010]; const int inf = 987654321; int main(void) { int n; scanf("%d", &n); vector<Point> v(n); for(int i=0; i<n; i++) { int x, y; scanf("%d%d", &x, &y); v[i] = Point(x, y); } for(int i=0; i<n-1; i++) { for(int j=i+1; j<n; j++) { int dd = v[i].distdist(v[j]); cost[i][j] = dd; cost[j][i] = dd; if(dd > 10 * 10) { continue; } route[i][j] = true; route[j][i] = true; } } for(int k=0; k<n; k++) { for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { route[i][j] = route[i][j] || (route[i][k] && route[k][j]); } } } int res = 0; for(int i=0; i<n-1; i++) { for(int j=i+1; j<n; j++) { if(!route[i][j]) { continue; } res = max(res, cost[i][j]); } } printf("%lf\n", sqrt(res) + 1 + (n>0)); return 0; }