QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#243402#7729. Permutation Compression IItnos#RE 1ms5928kbC++14697b2023-11-08 10:07:372023-11-08 10:07:38

Judging History

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

  • [2023-11-08 10:07:38]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5928kb
  • [2023-11-08 10:07:37]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int mxn=1e6+5;
int a[mxn],stk[mxn];
bool vis[mxn];
int main()
{
	int T=read();
	while(T--)
	{
		int n=read(),i,top=0,cnt=0;
		memset(vis,0,n+1);
		for(i=1;i<=n;i++)
			a[i]=read();
		for(i=n;i;i--)
		{
			for(;top&&a[stk[top]]<a[i];top--)
				vis[i]=1,top--,cnt++;
			stk[++top]=i;
		}
		printf("%d %d\n",n-cnt,cnt);
		for(i=1;i<=n;i++)
			if(vis[i])
				printf("%d ",i);
		puts("");
	}	
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5928kb

input:

2
3
3 1 2
3
1 2 3

output:

2 1
1 
3 0


result:

ok ok n = 3

Test #2:

score: -100
Runtime Error

input:

100000
7
2 6 7 1 4 3 5
6
1 5 6 3 2 4
3
1 2 3
3
2 1 3
14
9 6 13 10 4 7 5 14 1 12 8 3 2 11
3
1 2 3
14
1 9 3 14 5 7 4 6 12 2 8 11 13 10
8
7 1 3 6 2 5 8 4
16
9 3 4 8 7 16 10 6 11 1 14 2 13 12 5 15
3
3 1 2
33
9 10 23 3 16 1 19 32 25 4 5 31 28 7 22 27 30 8 6 17 2 14 13 29 20 33 26 18 24 11 12 15 21
2
2 1
...

output:


result: