QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729458#2455. Retribution!DJ_FWA 0ms4028kbC++171.8kb2024-11-09 17:09:552024-11-09 17:09:56

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 17:09:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4028kb
  • [2024-11-09 17:09:55]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cstring>
#define int long long
using namespace std;
const int N = 1e3+5;
int t=1, n, m, p;
int a[N], mp[N][N];
double ans=0;
struct note
{
    double x, y;
} jud[N], fea[N];
struct edge
{
    int a, b;
    double l;
} d1[N];
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 work(int x)
{
    vec.clear();
    memset(vis, 0, sizeof(vis));
    memset(vis1, 0, sizeof(vis1));
    memset(fea, 0, sizeof(fea));
    int cnt=0;
    for(int i=1; i<=x; i++)
    {
        cin>>fea[i].x>>fea[i].y;
    }

    cnt = 0;
    memset(vis,0,sizeof(vis));
    memset(vis1,0,sizeof(vis1));
    memset(d1,0,sizeof(d1));
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=p; j++)
        {
            d1[cnt].l = 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));;
            d1[cnt].a = i;
            d1[cnt].b = j;
            cnt++;
        }
    }
    sort(d1,d1+cnt,cmp);
    for(int i = 0; i<cnt; i++)
    {
        if(vis[d1[i].a]==0 && vis1[d1[i].b]==0)
        {
            vis[d1[i].a]=1;
            vis1[d1[i].b]=1;
            ans += d1[i].l;
        }
    }
}
void solve()
{
    cin>>n>>m>>p;
    for(int i=1; i<=n; i++)
    {
        cin>>jud[i].x>>jud[i].y;
    }
    work(m);
    work(p);
    printf("%.6lf",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++)
2 2 0
0 0
0 -2
0 -1
0 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3900kb

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: 4028kb

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: 4016kb

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'