QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#256254 | #6438. Crystalfly | Satsuki# | WA | 0ms | 3740kb | C++14 | 1.2kb | 2023-11-18 18:11:51 | 2023-11-18 18:11:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int ni=2e6;
int tr[ni];int n;
long long ans;
set<int>st;int siz,cnt;
vector<int>stk;
int ask(int a){
int res=0;
for(;a;a-=a&-a)
res+=tr[a];
return res;
}
void add(int a){
if(ask(a)-ask(a-1))return ;
for(;a<=n;a+=a&-a)tr[a]++;
}
void solve(){
for(int i=1;i<=n;i++)tr[i]=0;
stk.clear();ans=0;st.clear();
scanf("%d",&n);cnt=0;
for(int t=1;t<=n;t++){
int a;scanf("%d",&a);
st.insert(a);
if(t==1){
stk.push_back(a);
printf("0");siz=1;
continue;
}
if(a==stk.back())siz++;
else if(a>stk.back()){
add(stk.back());
stk.push_back(a);
siz=1;ans+=cnt;cnt=0;
}
else {
cnt+=(siz>1);
add(a);
}
ans+=ask(n)-ask(a);
// printf("[%d %d %ld %lld]",t,siz,stk.size()-1,ans);
if(st.size()==1)printf(" %lld",ans);
else printf(" %lld",ans+t+stk.size()-1-siz);
}
printf("\n");
}
int main(){
int t;scanf("%d",&t);
for(int i=1;i<=t;i++)
solve();return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3740kb
input:
2 5 1 10 100 1000 10000 1 2 1 1 1 1 2 1 3 2 4 2 5 5 1 10 100 1000 10000 1 3 1 1 1 1 2 1 3 2 4 2 5
output:
0 3 6 9 12 0
result:
wrong answer 1st numbers differ - expected: '10101', found: '0'