QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89001#5466. Permutation CompressionshihoghmeanWA 2ms3464kbC++142.6kb2023-03-18 10:40:302023-03-18 10:40:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-18 10:40:33]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3464kb
  • [2023-03-18 10:40:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define py puts("YES")
#define pn puts("NO")
#define pt puts("")
#define pb push_back
#define wt(x) write(x),puts("")
#define tx printf("fds")
#define mp make_pair
#define fi first
#define se second
inline int read(){
	int x=0,k=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') k=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+ch-48;
		ch=getchar();
	}
	return x*k;
}
void write(int x){
	if(x<0){
		x=-x;
		putchar('-');
	}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
int power(int x,int y,int mod){
	int num=1;
	while(y){
		if(y&1) num=(num*x)%mod;
		x=x*x%mod;
		y>>=1;
	}
	return num;
}
int mul(int x,int y,int mod){
	int num=0;
	while(y){
		if(y&1) num=(num+x)%mod;
		x=(x+x)%mod;
		y>>=1;
	}
	return num;
}
const int N=1e6+7,mod=998244353;
int n,m,tot,cnt,ans,k;
int a[N],b[N],c[N],d[N];
int l[N],r[N];
int st[N],top;
struct tree{
	int max;
}t[N];
void pu(int id){
	t[id].max=max(t[id<<1].max,t[id<<1|1].max);
}
void build(int id,int l,int r){
	if(l==r){
		t[id].max=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(id<<1,l,mid);
	build(id<<1|1,mid+1,r);
	pu(id);
}
void update(int id,int l,int r,int x){
	if(l==r){
		t[id].max=0;
		return ;
	}
	int mid=(l+r)>>1;
	if(x<=mid) update(id<<1,l,mid,x);
	else update(id<<1|1,mid+1,r,x);
	pu(id);
}
int query(int id,int l,int r,int L,int R){
	if(L<=l&&r<=R){
		return t[id].max;
	}
	int mid=(l+r)>>1;
	int p=0;
	if(L<=mid) p=max(p,query(id<<1,l,mid,L,R));
	if(mid<R) p=max(p,query(id<<1|1,mid+1,r,L,R));
	pu(id);
	return p;
}
int get(int x){
	int now=d[x];
	int num=1;
	int l=now+1,r=n;
	int an=now;
	while(l<=r){
		int mid=(l+r)>>1;
		if(query(1,1,n,now+1,mid)>x) r=mid-1;
		else l=mid+1,an=mid;
	}
	num+=an-now;
	l=1;
	r=now-1;
	an=now;
	while(l<=r){
		int mid=(l+r)>>1;
		if(query(1,1,n,mid,now-1)>x) l=mid+1;
		else r=mid-1,an=mid;
	}
	num+=now-an;
	return num;
}
signed main(){
	int tt=read();
	while(tt--){
		n=read();m=read();
		k=read();
		fo(i,1,n) b[i]=1;
		fo(i,1,n) a[i]=read(),d[a[i]]=i;
		fo(i,1,m) b[read()]=0;
		fo(i,1,k) c[i]=read();
		sort(c+1,c+k+1);
		build(1,1,n);
		int now=n-m,fl=0;
		fr(i,n,1){
			if(b[i]){
				int x=get(i);
				if(now<=0){
					fl=1;
					pn;
					break;
				}
				if(x>=c[now]){
					now--;
					update(1,1,n,d[i]);
				}
				else{
					fl=1;
					pn;
					break;
				}
			}
		}
		if(fl) continue;
		py;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3340kb

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: 3464kb

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
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
Y...

result:

wrong answer 28th lines differ - expected: 'NO', found: 'YES'