QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18807#1877. Matryoshka DollsLcyanstarsCompile Error//C490b2022-01-27 13:55:092022-05-18 04:05:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 04:05:17]
  • 评测
  • [2022-01-27 13:55:09]
  • 提交

answer

#include <bits/stdc++.h>

int idx[500050],a[500050],b[500050];

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i <= n;i++)
	{
		scanf("%d",a+i);
		b[i]=a[i],idx[a[i]]=i;
	}
	for(int i=0;i<m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		std::stable_sort(b+l,b+r+1);
		long long res=0;
		for(int j=l;j<r;j++)
		{
			res += abs(idx[b[j]]-idx[b[j+1]]);
			b[j]=a[j];
		}
		b[r]=a[r];
		printf("%lld\n",res);
	}
	return 0;
}
/*
5 2
5 4 2 3 1
3 4
2 5
*/

详细

answer.code:1:10: fatal error: bits/stdc++.h: No such file or directory
 #include <bits/stdc++.h>
          ^~~~~~~~~~~~~~~
compilation terminated.