QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#256254#6438. CrystalflySatsuki#WA 0ms3740kbC++141.2kb2023-11-18 18:11:512023-11-18 18:11:51

Judging History

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

  • [2023-11-18 18:11:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2023-11-18 18:11:51]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'