QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#697463#6434. Paimon Sortingfsy_juruo#WA 0ms3796kbC++171.5kb2024-11-01 14:12:062024-11-01 14:12:09

Judging History

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

  • [2024-11-01 14:12:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-11-01 14:12:06]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define LL long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<long long,int> pii;
tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> T;
const int maxN=1e5+100;
int t, n;
LL a[maxN];

int main() {
    scanf("%d",&t);
    while(t--) {
        T.clear();
        scanf("%d",&n);
        LL ans = 0;
        for(int i = 1; i <= n; i++) {
            scanf("%lld",a+i);
        }
        if(n==1){
            puts("0");
            continue;
        }
        
        else printf("0 ");
        T.insert(make_pair(a[1],1));
        int p=0;
        for(int i=2;i<=n;i++){
            LL maxx=(--T.end())->first;
            if(a[i]>maxx){
                ans+=2;
                if (p != 0) ans += i - p;
                p=0;
                T.insert(make_pair(a[i],i));
            }
            else{
                if(a[i]==maxx) {
                    if(p == 0) p = i;
                }
                LL rk=T.order_of_key(make_pair(a[i],n));
                if(T.lower_bound(make_pair(a[i]-1,n))->first!=a[i])T.insert(make_pair(a[i],i));
                //cout<<"aaa "<<i<<" "<<T.order_of_key(make_pair(a[i],n))<<endl;
                //cout<<endl<<"rk: "<<rk<<endl;
                ans+=T.size()-rk;
            }
            if(i!=n)printf("%lld ",ans);
            else printf("%lld",ans);
        }
        puts("");
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3796kb

input:

3
5
2 3 2 1 5
3
1 2 3
1
1

output:

0 2 3 6 8
0 2 4
0

result:

wrong answer 1st lines differ - expected: '0 2 3 5 7', found: '0 2 3 6 8'