QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#774667 | #9792. Ogre Sort | ucup-team3161# | WA | 1ms | 7984kb | C++17 | 698b | 2024-11-23 13:39:12 | 2024-11-23 13:39:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,cnt,a[N],b[N],bt[N];
vector<int> ans;
bool fl=0;
void upd(int x,int w)
{
for(;x<=n;x+=x&-x)
bt[x]+=w;
}
int qry(int x)
{
int res=0;
for(;x;x-=x&-x)
res+=bt[x];
return res;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
scanf("%d",&a[i]),b[a[i]]=i;
for(int i=n;i;--i)
{
if(i<n && b[i]>b[i+1]) fl=1;
if(fl)
{
++cnt;
ans.push_back(b[i]-qry(b[i]));
upd(b[i],1);
}
}
printf("%d %d\n",cnt,cnt);
for(auto i:ans)
printf("%d 1\n",i);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7984kb
input:
4 1 2 4 3
output:
3 3 4 1 2 1 1 1
result:
wrong answer participant used a nop move