QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#520293 | #5466. Permutation Compression | no_RED_no_DEAD | WA | 2ms | 11928kb | C++20 | 1.5kb | 2024-08-15 12:30:58 | 2024-08-15 12:31:00 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;
const ll M = 1e9 + 7;
ll n, m, k;
ll a[N], b[N], l[N];
ll pp[N], tmp[N];
bool inorder() {
ll j = 1;
for (int i = 1; i <= n; i ++)
if (a[i] == b[j]) j ++;
return (j == m + 1);
}
void buffalo() {
for (int i = 1; i <= n; i ++) pp[a[i]] = 1;
for (int i = 1; i <= m; i ++) pp[b[i]] = 0;
sort(l + 1, l + k + 1); k = n - m;
for (int i = k; i >= 1; i --) {
bool ok = 0; ll del;
for (int j = l[i]; j <= n; j ++) {
ll lc = j - l[i] + 1, rc = j, mx = -1e18;
for (int x = lc; x <= rc; x ++) mx = max(mx, a[x]);
if (pp[mx] == 1) {ok = 1; del = mx; break;}
}
if (!ok) {cout << "NO\n"; return;}
ll sz = 0;
for (int j = 1; j <= n; j ++)
if (a[j] != del) tmp[++ sz] = a[j];
n = sz;
for (int j = 1; j <= n; j ++)
a[j] = tmp[j];
}
cout << "YES\n";
}
void doTest(ll testID) {
cin >> n >> m >> k;
for (int i = 1; i <= n; i ++) cin >> a[i];
for (int i = 1; i <= m; i ++) cin >> b[i];
for (int i = 1; i <= k; i ++) cin >> l[i];
if (k + m < n) {cout << "NO\n"; return;}
if (!inorder()) {cout << "NO\n"; return;}
buffalo();
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int test = 1;
cin >> test;
for (int _ = 1; _ <= test; _ ++) doTest(test);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 11796kb
input:
3 5 2 3 5 1 3 2 4 5 2 1 2 4 5 5 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 3 2 2 3 1 2 3 2 2 3
output:
YES YES NO
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 11928kb
input:
100 2 1 2 2 1 2 1 1 2 1 2 1 2 1 2 2 2 1 1 1 2 1 2 6 1 5 3 4 2 5 6 1 3 5 2 1 1 1 6 1 6 2 1 3 6 4 5 1 4 1 2 2 1 4 3 3 2 2 1 3 2 1 3 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 2 1 2 4 4 3 2 1 3 4 2 1 3 4 4 3 1 1 1 1 1 1 1 6 5 1 6 2 5 4 3 1 6 2 4 3 1 4 1 1 1 1 1 1 6 5 3 3 6 1 4 5 2 3 6 1 4 2 3 3 4 4 3 4 3 4 ...
output:
YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES NO YES YES NO YES YES YES YES YES YES YES YES YES YES NO NO NO NO YES NO NO YES NO YES YES YES NO YES YES YES NO YES NO NO YES YES YES YES NO YES NO YES YES YES YES YES YES YES NO YES YES YES YES YES YES YE...
result:
wrong answer 9th lines differ - expected: 'YES', found: 'NO'