QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617241#1964. Stock Price PredictionAfterlife#WA 414ms66088kbC++202.1kb2024-10-06 14:36:022024-10-06 14:36:03

Judging History

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

  • [2024-10-06 14:36:03]
  • 评测
  • 测评结果:WA
  • 用时:414ms
  • 内存:66088kb
  • [2024-10-06 14:36:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const ull base=1313131313,mod=(1ull<<61)-1;
const int N=1000100;
ull pw[N],Q;
int c[N],a[N],n,m,wc[N],wa[N];
int pc[N],pa[N];
bool ok[N];
class Segment_Tree{
    struct node{
        int siz;
        ull h;
    }t[N<<2];
    #define ls u<<1
    #define rs u<<1|1
    inline void update(int u){
        t[u].siz=t[ls].siz+t[rs].siz;
        t[u].h=(t[ls].h+(__int128)t[rs].h*pw[t[ls].siz])%mod;
    }
    void _cha(int u,int L,int R,int p,int x,int w){
        if(L==R){
            t[u].h+=x*w;
            t[u].siz+=w;
            return;
        }
        int mid=(L+R)>>1;
        p<=mid?_cha(ls,L,mid,p,x,w):_cha(rs,mid+1,R,p,x,w);
        update(u);
    }
public:
    void Change(int p,int x,int w){
        _cha(1,1,n,p,x,w);
    }
    ull Get(){
        return t[1].h;
    }
}T;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>m>>n;
    pw[0]=1;
    for(int i=1;i<=n;++i){
        pw[i]=(__int128)pw[i-1]*base%mod;
    }
    ull sum=0;
    for(int i=0;i<m;++i){
        sum=(sum+pw[i])%mod;
    }
    for(int i=1;i<=m;++i){
        cin>>wc[i];
        pc[i]=i;
    }
    for(int i=1;i<=n;++i){
        cin>>wa[i];
        pa[i]=i;
    }
    sort(pc+1,pc+m+1,[&](int i,int j){
        return wc[i]==wc[j]?i<j:wc[i]<wc[j];
    });
    sort(pa+1,pa+n+1,[&](int i,int j){
        return wa[i]==wa[j]?i<j:wa[i]<wa[j];
    });
    for(int i=1;i<=m;++i){
        c[pc[i]]=i;
    }
    for(int i=1;i<=n;++i){
        a[pa[i]]=i;
    }
    for(int i=m;i>=1;--i){
        Q=((__int128)Q*base+pc[i])%mod;
    }
    for(int i=1;i<m;++i){
        T.Change(a[i],i,1);
    }
    for(int i=m;i<=n;++i){
        if(i>m){
            T.Change(a[i-m],i-m,-1);
        }
        T.Change(a[i],i,1);
        if(T.Get()==(Q+(__int128)(i-m)*sum)%mod){
            ok[i]=1;
        }
    }
    bool OK=0;
    for(int i=1;i<=n;++i){
        if(ok[i]){
            cout<<i-m+1<<' ';
            OK=1;
        }
    }
    if(!OK)cout<<'0';
    cout<<'\n';
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 414ms
memory: 66088kb

input:

10000 1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...97 989998 989999 990000 990001 '

Test #2:

score: -100
Wrong Answer
time: 408ms
memory: 64516kb

input:

10000 1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

1 2 10002 20002 30002 40002 50002 60002 70002 80002 90002 100002 110002 120002 130002 140002 150002 160002 170002 180002 190002 200002 210002 220002 230002 240002 250002 260002 270002 280002 290002 300002 310002 320002 330002 340002 350002 360002 370002 380002 390002 400002 410002 420002 430002 4400...

result:

wrong answer 1st lines differ - expected: '2 10002 20002 30002 40002 5000...002 950002 960002 970002 980002', found: '1 2 10002 20002 30002 40002 50...02 950002 960002 970002 980002 '