QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18997 | #1877. Matryoshka Dolls | 123qwq | Compile Error | / | / | C | 1.3kb | 2022-01-27 18:16:51 | 2022-05-18 04:05:31 |
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:31]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-01-27 18:16:51]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
int a[500010],b[500010];
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
inline void print(int x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)print(x/10);
putchar(x%10+'0');
}
inline find(int l,int r,int x)
{
for(int i=l;i<=r;i++)
if(a[i]==x)
return i;
}
inline void qsort(int l,int r)
{
int mid=b[(l+r)>>1],i=l,j=r;
do
{
while(b[i]<mid)i++;
while(b[j]>mid)j--;
if(i<=j)
{
b[i]^=b[j]^=b[i]^=b[j];
i++;
j--;
}
}while(i<=j);
if(l<j)qsort(l,j);
if(i<r)qsort(i,r);
}
int main()
{
//freopen("rrads.in","r",stdin);
//freopen("rrads.out","w",stdout);
int n=read(),m=read();
for(register int i=1;i<=n;++i)a[i]=read();
while(m--)
{
int l=read(),r=read(),ans=0;
for(register int i=l;i<=r;++i)
b[i]=a[i];
qsort(l,r);
for(register int i=l;i<r;++i)
ans+=abs(find(l,r,b[i])-find(l,r,b[i+1]));
print(ans);
puts("");
}
return 0;
}
詳細信息
answer.code:1:9: fatal error: bits/stdc++.h: No such file or directory #include<bits/stdc++.h> ^~~~~~~~~~~~~~~ compilation terminated.