QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#680696#8333. GiftAuroraKelseyWA 0ms1600kbC++141.1kb2024-10-26 22:13:102024-10-26 22:13:11

Judging History

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

  • [2024-10-26 22:13:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1600kb
  • [2024-10-26 22:13:10]
  • 提交

answer

#include <cstdio>
#include <algorithm>
using namespace std;
const int N=1e3+5;
const int M=2e4+5;
struct node{
	int b,opos;
	bool operator <(const node &other)const{
		if(b!=other.b)return b<other.b;
		return opos<other.opos; 
	}
}a[N];
int n,tot,cnt,nowcnt,x[N],pos[N],ans1[M],ans2[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].b);
		a[i].opos=i;
	}
	sort(a+1,a+n+1);
	a[0].b=-1;
	for(int i=1;i<=n;i++){
		if(a[i].b!=a[i-1].b){
			x[++tot]=a[i].b;
			pos[tot]=i;
		}
	}
	pos[tot+1]=n+1;
	if(tot==1){
		cnt=x[1];
		printf("%d\n",cnt);
		for(int i=0;i<x[1];i++){
			printf("%d %d\n",1,i);
		}
		return 0;
	}
	nowcnt=0;
	for(int i=0;i<x[1];i++){
		ans1[++nowcnt]=1,ans2[nowcnt]=i;
	}
	for(int i=2;i<=tot;i++){
		int dc1=n-pos[i];
		for(int j=pos[i];j<=n;j++){
			ans1[++nowcnt]=2,ans2[nowcnt]=a[j].opos;
		}
		int dc2=x[i]-x[i-1]-1;
		for(int j=x[i-1]+1;j<x[i];j++){
			ans1[++nowcnt]=1,ans2[nowcnt]=j;
		}
	}
	printf("%d\n",nowcnt);
	for(int i=1;i<=nowcnt;i++){
		printf("%d %d\n",ans1[i],ans2[i]);
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1600kb

input:

6
1 2
1 3
1 4
1 5
1 6
2 3

output:

7
1 0
2 2
2 4
2 6
2 4
2 6
2 6

result:

wrong answer 1st numbers differ - expected: '10', found: '7'