QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#187766 | #5466. Permutation Compression | Coke | WA | 1ms | 11804kb | C++14 | 1.1kb | 2023-09-24 21:48:39 | 2023-09-24 21:48:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cerr<<#x<<' '<<x<<endl;
typedef pair<int,int>PII;
typedef long long LL;
constexpr int N=200010,mod=1e9+7;
int a[N],b[N],l[N],pre[N],pos[N];
PII cnt[N];
signed main()
{
//freopen(".in","r",stdin);freopen(".out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t;
cin>>t;
while(t--)
{
int n,m,k;
cin>>n>>m>>k;
for(int i=1;i<=n;i++)cin>>a[i],pos[a[i]]=i;
a[n+1]=n+1;
set<int>s1,s2;
for(int i=1;i<=m;i++)cin>>b[i],s1.insert(b[i]);
for(int i=1;i<=k;i++)cin>>l[i],s2.insert(l[i]);
set<int>s;
s.insert(0);
s.insert(n+1);
for(int i=n;i>=1;i--)
{
auto p=s.lower_bound(pos[i]);
cnt[i].first=*p-*prev(p)-1;
cnt[i].second=i;
s.insert(pos[i]);
}
sort(cnt+1,cnt+n+1);
int f=1;
for(int i=n;i>=1;i--)
{
if(s1.count(cnt[i].second))continue;
auto it=s2.upper_bound(cnt[i].first);
if(it==s2.begin())
{
f=0;
break;
}
it--;
s2.erase(it);
}
if(f)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 9764kb
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: 0ms
memory: 11804kb
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 NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES NO YES YES YES YES NO YES YES YES YES YES NO NO YES YES YES NO NO NO NO YES NO YES YES YES YES YES YES NO YES NO YES NO YES NO NO YES YES YES YES YES YES NO YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES...
result:
wrong answer 4th lines differ - expected: 'YES', found: 'NO'