QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729529 | #2455. Retribution! | DJ_F | WA | 0ms | 3924kb | C++17 | 2.3kb | 2024-11-09 17:17:23 | 2024-11-09 17:17:29 |
Judging History
answer
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#define int long long
using namespace std;
const int N = 1e3+5;
int t=1, n, m, p;
int a[N], mp[N][N];
struct note {
int x, y;
}jud[N], tar[N], fea[N];
struct edge {
int a, b;
double l;
};
bool cmp (edge x, edge y) {
if(x.l==y.l) {
if(x.a==y.a) {
return x.b < y.b;
}
return x.a < y.a;
}
return x.l < y.l;
}
vector<edge> vec;
bool vis[N], vis1[N];
void solve()
{
double ans=0;
int cnt=0;
cin>>n>>m>>p;
for(int i=1; i<=n; i++)
{
cin>>jud[i].x>>jud[i].y;
}
for(int i=1; i<=m; i++)
{
cin>>tar[i].x>>tar[i].y;
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
double dis = sqrt((jud[i].x-tar[i].x)*(jud[i].x-tar[i].x)+(jud[i].y-tar[i].y)*(jud[i].y-tar[i].y));
vec.push_back({i,j,dis});
}
}
sort(vec.begin(), vec.end(), cmp);
for(edge i: vec)
{
// cout<<i.a<<' '<<i.b<<' '<<i.l<<'\n';
if(vis[i.a]==0 && vis1[i.b]==0)
{
ans += i.l;
vis[i.a]=1;
vis1[i.b]=1;
cnt++;
if(cnt==n) break;
}
}
vec.clear();
cnt=0;
for(int i=1; i<=p; i++)
{
vis[i]=0;
vis1[i]=0;
cin>>fea[i].x>>fea[i].y;
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
double dis = sqrt((jud[i].x-fea[i].x)*(jud[i].x-fea[i].x)+(jud[i].y-fea[i].y)*(jud[i].y-fea[i].y));
vec.push_back({i,j,dis});
}
}
sort(vec.begin(), vec.end(), cmp);
for(edge i: vec)
{
// cout<<i.a<<' '<<i.b<<' '<<i.l<<'\n';
if(vis[i.a]==0 && vis1[i.b]==0)
{
ans += i.l;
vis[i.a]=1;
vis1[i.b]=1;
cnt++;
if(cnt==n) break;
}
}
cout<<fixed<<setprecision(6)<<ans;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
// cin>>t;
while(t--) {
solve();
}
}
/*
for(int i=1; i<=n; i++)
3 3 3
1 0
2 0
1 3
0 0
3 0
2 2
1 1
2 1
3 2
7.650282
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
2 2 2 1 0 2 0 0 0 3 0 1 1 2 1
output:
4.000000
result:
ok found '4.0000000', expected '4.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
1 1 1 5875 3435 -743 8951 2325 7352
output:
13901.685460
result:
ok found '13901.6854600', expected '13901.6854603', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3848kb
input:
2 2 2 0 0 10 0 6 0 20 0 6 0 20 0
output:
32.000000
result:
wrong answer 1st numbers differ - expected: '48.0000000', found: '32.0000000', error = '0.3333333'