QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#531635#2337. AzulejosSwarthmore#WA 498ms42268kbC++141.7kb2024-08-24 21:27:182024-08-24 21:27:19

Judging History

This is the latest submission verdict.

  • [2024-08-24 21:27:19]
  • Judged
  • Verdict: WA
  • Time: 498ms
  • Memory: 42268kb
  • [2024-08-24 21:27:18]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

struct rec {
    int p, h;
    int id;
    bool operator<(const rec & r) const {
        if (p != r.p) return p < r.p;
        return h < r.h;
    }
};

int main() {
    int n;
    cin >> n;
    vector<rec> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].p;
        a[i].id = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i].h;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i].p;
        b[i].id = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i].h;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> ansa(n), ansb(n);
    int i = 0, j = 0;
    set<pair<int, int>> ah, bh;
    int ct = 0;
    while (ct < n) {
        if (ah.empty()) {
            int cur = a[i].p;
            while (i < n && a[i].p == cur) {
                ah.insert({a[i].h, a[i].id});
                i++;
            }
        }
        if (bh.empty()) {
            int cur = b[j].p;
            while (j < n && b[j].p == cur) {
                bh.insert({b[j].h, b[j].id});
                j++;
            }
        }
        // Find the one lower than 
        auto ita = ah.end();
        ita--;
        auto it = bh.lower_bound({ita->first, -1});
        if (it == bh.begin()) {
            cout << "impossible\n";
            return 0;
        }
        it--;
        ansa[ct] = ita->second;
        ansb[ct] = it->second;
        ct++;
        ah.erase(ita);
        bh.erase(it); 
    }
    for (int i = 0; i < n; i++) {
        cout << ansa[i] + 1 << " ";
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
        cout << ansb[i] + 1 << " ";
    }
    cout << endl;
}

詳細信息

Test #1:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

Test #3:

score: 0
Accepted
time: 0ms
memory: 3600kb

Test #4:

score: 0
Accepted
time: 0ms
memory: 3608kb

Test #5:

score: 0
Accepted
time: 0ms
memory: 3600kb

Test #6:

score: 0
Accepted
time: 0ms
memory: 3544kb

Test #7:

score: 0
Accepted
time: 0ms
memory: 3544kb

Test #8:

score: 0
Accepted
time: 0ms
memory: 3600kb

Test #9:

score: 0
Accepted
time: 0ms
memory: 3640kb

Test #10:

score: 0
Accepted
time: 0ms
memory: 3604kb

Test #11:

score: 0
Accepted
time: 0ms
memory: 3832kb

Test #12:

score: 0
Accepted
time: 498ms
memory: 42268kb

Test #13:

score: 0
Accepted
time: 0ms
memory: 3544kb

Test #14:

score: 0
Accepted
time: 1ms
memory: 3684kb

Test #15:

score: 0
Accepted
time: 8ms
memory: 4320kb

Test #16:

score: 0
Accepted
time: 0ms
memory: 3548kb

Test #17:

score: 0
Accepted
time: 0ms
memory: 3800kb

Test #18:

score: 0
Accepted
time: 0ms
memory: 3608kb

Test #19:

score: -100
Wrong Answer
time: 0ms
memory: 3600kb