QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#99813#5466. Permutation Compressionlgvc#WA 3ms9572kbC++2.3kb2023-04-23 19:41:542023-04-23 19:41:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-23 19:41:56]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:9572kb
  • [2023-04-23 19:41:54]
  • 提交

answer

//这回只花了114514min就打完了。
//真好。记得多手造几组。
#include <bits/stdc++.h>
//#define int long long
#define pai 3.141592653589793238462643383279502884197169399375105820
#define MOD 1000000007
#define eps 0.00000001
inline int min(int a,int b) {return a<b?a:b;}
inline int max(int a,int b) {return a>b?a:b;}
#define ULL unsigned long long
#define LL long long
#define INF 0x3f3f3f3f
#define INF_LL 0x3f3f3f3f3f3f3f3f
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
	if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
	*pp++=ch;
}
inline void pcc(){
	fwrite(buf2,1,pp-buf2,stdout);
	pp=buf2;
}
inline int read(void) {
	int w=1;
	register int x(0);register char c(getchar());
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w*x;
}
void write(int x) {
	if(x<0) pc('-'),x=-x;
	static int sta[20];
	int top=0;
	do {
		sta[top++]=x%10,x/=10;
	} while(x);
	while(top) pc(sta[--top]+48);
}
void we(int x) {
	write(x);
	pc('\n');
}
inline bool cmp_xi(int a,int b) {return a<b;}
inline bool cmp_da(int a,int b) {return a>b;}
int T,N,M,K,a[200009],p[200009],b[200009],v[200009],l[200009],t[200009];
signed main(void) {
    //freopen("m.in","r",stdin);
    //freopen("m.out","w",stdout);
	T=read();
	while(T--) {
		N=read();M=read();K=read();
		for(int i=1;i<=N;i++) {
			a[i]=read();
			v[i]=0;
			p[a[i]]=i;
		}
		for(int i=1;i<=M;i++) {
			b[i]=read();
			v[b[i]]=1;
		}
		for(int i=1;i<=K;i++) l[i]=read();
		bool ff=0;
		for(int i=1;i<M;i++) {
			if(p[b[i]]>p[b[i+1]]) ff=1;
		}
		if(ff) {
			printf("NO\n");
			continue;
		}
		std::set<int> ss;
		ss.insert(0);ss.insert(N+1);
		int qq=0;
		for(int i=N;i>=1;i--) {
			if(v[i]) {
				ss.insert(p[i]);
				continue;
			}
			ss.insert(p[i]);
			auto it1=ss.find(p[i]);
			auto it2=it1;
			it1--;
			it2++;
			t[++qq]=(*it2)-(*it1)-1;
			ss.erase(p[i]);
		}
		std::sort(t+1,t+qq+1);
		std::sort(l+1,l+K+1);
		if(qq>K) {
			printf("NO\n");
			continue;
		}
		for(int i=1;i<=qq;i++) {
			if(t[i]<l[i]) ff=1;
		}
		if(ff) {
			printf("NO\n");
			continue;
		}
		printf("YES\n");		
	}
    return 0;
}


详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 9520kb

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: 3ms
memory: 9572kb

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

result:

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