QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#389830 | #2337. Azulejos | neal2022 | WA | 0ms | 3844kb | C++23 | 1.5kb | 2024-04-14 20:12:13 | 2024-04-14 20:12:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n;
std::cin >> n;
auto get = [&]() {
std::map<int, std::set<std::array<int, 2>>> a;
std::vector<int> xs(n), ys(n);
for (auto& x : xs) std::cin >> x;
for (auto& y : ys) std::cin >> y;
for (int i = 0; i < n; i++) {
a[xs[i]].insert({ys[i], i});
}
return a;
};
auto a = get();
auto b = get();
std::vector<int> a_order, b_order;
while (a.size() && b.size()) {
auto& a_first = a.begin()->second;
auto& b_first = b.begin()->second;
if (a_first.size() >= b_first.size()) {
for (auto& [h, bi] : b_first) {
b_order.push_back(bi);
auto a_it = a_first.upper_bound({h, n});
if (a_it == a_first.end()) {
std::cout << "impossible\n";
return 0;
}
a_order.push_back((*a_it)[1]);
a_first.erase(a_it);
}
b.erase(b.begin());
} else {
for (auto& [h, ai] : a_first) {
a_order.push_back(ai);
auto b_it = b_first.upper_bound({h, 0});
if (b_it == b_first.begin()) {
std::cout << "impossible\n";
return 0;
}
b_it--;
b_order.push_back((*b_it)[1]);
b_first.erase(b_it);
}
a.erase(a.begin());
}
}
for (auto& x : a_order) std::cout << x + 1 << " ";
std::cout << "\n";
for (auto& x : b_order) std::cout << x + 1 << " ";
std::cout << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3680kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3576kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3636kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3636kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3844kb
Test #11:
score: -100
Wrong Answer
time: 0ms
memory: 3648kb