QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#180583 | #6680. Heap | rgnerdplayer | Compile Error | / | / | C++20 | 2.2kb | 2023-09-16 00:38:21 | 2023-09-16 00:38:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&]() {
int n;
cin >> n;
vector<int> v(n + 1), a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<int> ans(n + 1);
bool ok = true;
for (int i = n; i > 0; i--) {
vector<int> path;
int u = i;
int isMax = -1;
while (true) {
if (u == 0) {
ok = false;
break;
}
path.push_back(u);
if (a[u] == v[i]) {
if (u / 2 > 0) {
if (a[u / 2] > a[u]) {
if (isMax == 0) {
ok = false;
}
isMax = 1;
} else if (a[u / 2] < a[u]) {
if (isMax == 1) {
ok = false;
}
isMax = 0;
}
}
break;
} else if (a[u] > v[i]) {
if (isMax == 1) {
ok = false;
}
isMax = 0;
} else if (a[u] < v[i]) {
if (isMax == 0) {
ok = false;
}
isMax = 1;
}
u /= 2;
}
if (!ok) {
cout << "Impossible\n";
return;
}
ans[i] = max(0, isMax);
while (int(path.size()) > 1) {
swap(a[path.end()[-2]], a[path.back()]);
path.pop_back();
}
}
for (int i = 1; i <= n; i++) {
cout << ans[i];
}
cout << '\n';
};
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
answer.code:93:1: error: extended character is not valid in an identifier 93 | | ^ answer.code:93:1: error: ‘ ’ does not name a type 93 | | ^