QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113365 | #5466. Permutation Compression | kemuniku | Compile Error | / | / | C++ | 3.0kb | 2023-06-17 10:57:34 | 2023-06-17 10:57:37 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-17 10:57:37]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-17 10:57:34]
- 提交
answer
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
std::vector<int> solve() {
int N, M, K;
std::cin >> N >> M >> K;
std::vector<int> A(N), B(M), L(K);
for (int i = 0; i < N; ++i)
std::cin >> A[i];
for (int i = 0; i < M; ++i)
std::cin >> B[i];
for (int i = 0; i < K; ++i)
std::cin >> L[i];
std::vector<int> rB(B.rbegin(), B.rend());
for (int i = 0; i < N; ++i) {
if (A[i] == rB.back()) {
rB.pop_back();
}
if (rB.empty()) {
break;
}
}
if (!rB.empty()) {
return {0}; // "NO"
}
std::set<int> sB(B.begin(), B.end());
std::vector<int> ok(N, -1);
std::priority_queue<int, std::vector<int>, std::greater<int>> q;
std::vector<int> v_to_i(N + 1, -1);
for (int i = 0; i < N; ++i)
v_to_i[A[i]] = i;
std::vector<int> start(N + 1, -1);
std::set<int> st;
for (int i = N - 1; i >= 0; --i) {
if (sB.count(A[i]) > 0) {
while (!q.empty() && q.top() < A[i]) {
int x = q.top();
q.pop();
ok[v_to_i[x]] = std::distance(st.begin(), st.lower_bound(x)) - start[x];
}
} else {
q.push(A[i]);
start[A[i]] = std::distance(st.begin(), st.lower_bound(A[i]));
}
st.insert(A[i]);
}
while (!q.empty()) {
int x = q.top();
q.pop();
ok[v_to_i[x]] = std::distance(st.begin(), st.lower_bound(x)) - start[x];
}
std::priority_queue<int, std::vector<int>, std::greater<int>> q;
std::set<int> sB(B.begin(), B.end());
std::vector<int> ok(N, -1);
std::set<int> st;
for (int i = 0; i < N; ++i) {
if (sB.count(A[i]) > 0) {
while (!q.empty() && q.top() < A[i]) {
int x = q.top();
q.pop();
ok[v_to_i[x]] += std::distance(st.begin(), st.lower_bound(x)) - start[x];
}
} else {
q.push(A[i]);
start[A[i]] += std::distance(st.begin(), st.lower_bound(A[i]));
}
st.insert(A[i]);
}
while (!q.empty()) {
int x = q.top();
q.pop();
ok[v_to_i[x]] += std::distance(st.begin(), st.lower_bound(x)) - start[x];
}
std::vector<int> li;
for (int i = 0; i < N; ++i) {
if (ok[i] != -1)
li.push_back(ok[i]);
}
std::sort(li.begin(), li.end());
std::sort(L.begin(), L.end());
if (li.size() > L.size())
return {0};
for (int i = 0; i < li.size(); ++i) {
if (li[i] < L[i])
return {0};
}
return {1};
}
int main() {
int T;
std::cin >> T;
for (int i = 0; i < T; ++i) {
std::vector<int> result = solve();
if (result[0] == 1)
std::cout << "YES\n";
else
std::cout << "NO\n";
}
return 0;
}
Details
answer.code: In function ‘std::vector<int> solve()’: answer.code:59:67: error: redeclaration of ‘std::priority_queue<int, std::vector<int>, std::greater<int> > q’ 59 | std::priority_queue<int, std::vector<int>, std::greater<int>> q; | ^ answer.code:33:67: note: ‘std::priority_queue<int, std::vector<int>, std::greater<int> > q’ previously declared here 33 | std::priority_queue<int, std::vector<int>, std::greater<int>> q; | ^ answer.code:60:19: error: redeclaration of ‘std::set<int> sB’ 60 | std::set<int> sB(B.begin(), B.end()); | ^~ answer.code:31:19: note: ‘std::set<int> sB’ previously declared here 31 | std::set<int> sB(B.begin(), B.end()); | ^~ answer.code:61:22: error: redeclaration of ‘std::vector<int> ok’ 61 | std::vector<int> ok(N, -1); | ^~ answer.code:32:22: note: ‘std::vector<int> ok’ previously declared here 32 | std::vector<int> ok(N, -1); | ^~ answer.code:62:19: error: redeclaration of ‘std::set<int> st’ 62 | std::set<int> st; | ^~ answer.code:39:19: note: ‘std::set<int> st’ previously declared here 39 | std::set<int> st; | ^~