結果
| 問題 |
No.94 圏外です。(EASY)
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-12-11 20:59:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,578 bytes |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 28,896 KB |
| 最終ジャッジ日時 | 2024-11-14 18:57:30 |
| 合計ジャッジ時間 | 786 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:71:42: error: ‘sqrt’ is not a member of ‘std’; did you mean ‘sort’?
71 | res = std::max(res, std::sqrt(dist[i][j]) + 2.0);
| ^~~~
| sort
main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
47 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:53:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
53 | scanf("%lld %lld", X+i, Y+i);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
typedef long long ll;
const int MAX_N = 1000;
class UnionFind{
public:
UnionFind(int n){
REP(i, n){
par[i] = i;
rank[i] = 0;
}
}
int find(int x){
if(x == par[x])return x;
return par[x] = find(par[x]);
}
bool same(int x, int y){
return find(x) == find(y);
}
void unite(int x, int y){
x = find(x);
y = find(y);
if(x == y){return;}
if(rank[x] > rank[y]){
par[y] = x;
}else{
par[x] = y;
if(rank[x] == rank[y]){rank[y]++;}
}
}
private:
int rank[MAX_N], par[MAX_N];
};
UnionFind uf(1000);
double dist[1000][1000];
int main(){
int N;
scanf("%d", &N);
if(N == 0){puts("1.0"); return 0;}
ll X[1000], Y[1000];
for(int i=0;i<N;i++){
scanf("%lld %lld", X+i, Y+i);
}
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
ll dx = X[i] - X[j], dy = Y[i] - Y[j];
ll d = dx * dx + dy * dy;
if(d <= 100){
uf.unite(i, j);
}
dist[i][j] = d;
}
}
double res = 2.0;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
if(uf.same(i, j)){
res = std::max(res, std::sqrt(dist[i][j]) + 2.0);
}
}
}
printf("%.10f\n", res);
}
tottoripaper