QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#187759 | #5466. Permutation Compression | Coke | WA | 2ms | 9608kb | C++14 | 1.0kb | 2023-09-24 21:43:26 | 2023-09-24 21:43:27 |
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],cnt[N],pos[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[pos[i]]=*p-*prev(p)-1;
s.insert(pos[i]);
}
int f=1;
for(int i=1;i<=n;i++)
{
if(s1.count(a[i]))continue;
auto it=s2.upper_bound(cnt[i]);
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: 2ms
memory: 9576kb
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: 9608kb
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'