QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708699#2455. Retribution!Tenshi#WA 0ms3840kbC++233.1kb2024-11-04 04:01:372024-11-04 04:01:37

Judging History

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

  • [2024-11-04 04:01:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-11-04 04:01:37]
  • 提交

answer

#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <tuple>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define sz(x) (long long)(x).size()


bool comp(pair<long long, pair<int, int>> a, pair<long long, pair<int, int>> b) {
    if (a.first < b.first) return true;
    if (a.first > b.first) return false;
    if (a.second.first < b.second.first) return true;
    if (a.second.first > b.second.first) return false;
    if (a.second.second < b.second.second) return true;
    if (a.second.second > b.second.second) return false;
    assert(1==0);
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int m, n, p;
    cin >> n >> m >> p;

    vector<tuple<long long, long long, int>> judges;
    for (int i = 0 ; i < n; i++) {
        long long x, y;
        cin >> x >> y;
        judges.emplace_back(x, y, i);
    }

    vector<tuple<long long, long long, int>> tar;
    for (int i = 0 ; i < m; i++) {
        long long x, y;
        cin >> x >> y;
        tar.emplace_back(x, y, i);
    }

    vector<tuple<long long, long long, int>> feather;
    for (int i = 0 ; i < p; i++) {
        long long x, y;
        cin >> x >> y;
        feather.emplace_back(x, y, i);
    }

    vector<bool> judgeAssigned(n, false), tarAssigned(m, false), featherAssigned(p, false);
    vector<pair<long long, pair<int, int>>> d;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            d.push_back({(get<0>(judges[i])-get<0>(tar[j]))*(get<0>(judges[i])-get<0>(tar[j])) + 
                           (get<1>(judges[i])-get<1>(tar[j]))*(get<1>(judges[i])-get<1>(tar[j])), 
                            {i, j}});
        }
    }
    sort(d.begin(), d.end(), comp);
    long double out = 0;
    rep(i, sz(d)) {
        if (judgeAssigned[d[i].second.first] or tarAssigned[d[i].second.second]) {
            continue;
        }
        cout << d[i].second.first << ' ' << d[i].second.second << endl; 
        out+=sqrt(d[i].first);
        judgeAssigned[d[i].second.first] = true;
        tarAssigned[d[i].second.second] = true;
    }

    d = vector<pair<long long, pair<int, int>>>();
    judgeAssigned = vector<bool>(n, false);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < p; j++) {
            d.push_back({(get<0>(judges[i])-get<0>(feather[j]))*(get<0>(judges[i])-get<0>(feather[j])) + 
                           (get<1>(judges[i])-get<1>(feather[j]))*(get<1>(judges[i])-get<1>(feather[j])), 
                            {i, j}});
        }
    }
    sort(d.begin(), d.end(), comp);
    rep(i, sz(d)) {
        if (judgeAssigned[d[i].second.first] or featherAssigned[d[i].second.second]) {
            continue;
        }
        out+=sqrt(d[i].first);
        cout << d[i].second.first << ' ' << d[i].second.second << endl; 

        judgeAssigned[d[i].second.first] = true;
        featherAssigned[d[i].second.second] = true;
    }

    cout << setprecision(10) << fixed << out << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

2 2 2
1 0
2 0
0 0
3 0
1 1
2 1

output:

0 0
1 1
0 0
1 1
4.0000000000

result:

wrong answer 1st numbers differ - expected: '4.0000000', found: '0.0000000', error = '1.0000000'