QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617212 | #1964. Stock Price Prediction | Afterlife# | WA | 266ms | 64456kb | C++20 | 2.0kb | 2024-10-06 14:27:28 | 2024-10-06 14:27:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const ull base=998244353;
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+t[rs].h*pw[t[ls].siz];
}
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]=pw[i-1]*base;
}
ull sum=0;
for(int i=0;i<m;++i){
sum+=pw[i];
}
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=Q*base+pc[i];
}
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+(i-m)*sum){
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 266ms
memory: 64456kb
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: 211ms
memory: 62820kb
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 '