QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#842221 | #2204. Border | CarroT1212 | AC ✓ | 750ms | 375124kb | C++14 | 944b | 2025-01-04 11:07:02 | 2025-01-04 11:07:02 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std; bool MEM;
using ll=long long; using ld=long double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
const int I=1e9;
const ll J=1e18,N=1e6+7,K=50,B=4e7+7;
int n,a[N],t[B][2],sz[B],cnn,nxt[K+7];
ll seed,ans;
void mian() {
scanf("%d%lld",&n,&seed);
for (int i=1;i<=n;i++) seed=(seed*13331+23333)%1000000007,a[i]=seed&1;
for (int l=1;l<=n;l++) {
int p=0;
for (int i=1,r=l,j=0;i<=K&&r<=n;i++,r++) {
if (!t[p][a[r]]) t[p][a[r]]=++cnn;
p=t[p][a[r]];
if (i>=2) {
while (j&&a[l+j]!=a[r]) j=nxt[j];
if (a[l+j]==a[r]) j++;
nxt[i]=j;
}
ans+=(ll)(i-nxt[i])*sz[p]++;
}
}
cout<<ans;
}
bool ORY; int main() {
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// while (1)
// int t; for (scanf("%d",&t);t--;)
mian();
cerr<<"\n"<<abs(&MEM-&ORY)/1048576<<"MB";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5752kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 5900kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 5900kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 5872kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 5924kb
Test #6:
score: 0
Accepted
time: 53ms
memory: 46284kb
Test #7:
score: 0
Accepted
time: 50ms
memory: 48116kb
Test #8:
score: 0
Accepted
time: 54ms
memory: 48352kb
Test #9:
score: 0
Accepted
time: 52ms
memory: 46236kb
Test #10:
score: 0
Accepted
time: 65ms
memory: 48100kb
Test #11:
score: 0
Accepted
time: 56ms
memory: 46244kb
Test #12:
score: 0
Accepted
time: 50ms
memory: 46200kb
Test #13:
score: 0
Accepted
time: 680ms
memory: 374304kb
Test #14:
score: 0
Accepted
time: 636ms
memory: 374340kb
Test #15:
score: 0
Accepted
time: 672ms
memory: 373656kb
Test #16:
score: 0
Accepted
time: 701ms
memory: 373120kb
Test #17:
score: 0
Accepted
time: 683ms
memory: 373744kb
Test #18:
score: 0
Accepted
time: 728ms
memory: 374084kb
Test #19:
score: 0
Accepted
time: 714ms
memory: 373968kb
Test #20:
score: 0
Accepted
time: 678ms
memory: 374616kb
Test #21:
score: 0
Accepted
time: 636ms
memory: 374672kb
Test #22:
score: 0
Accepted
time: 711ms
memory: 373084kb
Test #23:
score: 0
Accepted
time: 687ms
memory: 375012kb
Test #24:
score: 0
Accepted
time: 682ms
memory: 373804kb
Test #25:
score: 0
Accepted
time: 700ms
memory: 373688kb
Test #26:
score: 0
Accepted
time: 671ms
memory: 374412kb
Test #27:
score: 0
Accepted
time: 703ms
memory: 373916kb
Test #28:
score: 0
Accepted
time: 667ms
memory: 373716kb
Test #29:
score: 0
Accepted
time: 676ms
memory: 372956kb
Test #30:
score: 0
Accepted
time: 671ms
memory: 374860kb
Test #31:
score: 0
Accepted
time: 673ms
memory: 374908kb
Test #32:
score: 0
Accepted
time: 691ms
memory: 374968kb
Test #33:
score: 0
Accepted
time: 652ms
memory: 373892kb
Test #34:
score: 0
Accepted
time: 676ms
memory: 375124kb
Test #35:
score: 0
Accepted
time: 649ms
memory: 374132kb
Test #36:
score: 0
Accepted
time: 699ms
memory: 374812kb
Test #37:
score: 0
Accepted
time: 650ms
memory: 374080kb
Test #38:
score: 0
Accepted
time: 682ms
memory: 374448kb
Test #39:
score: 0
Accepted
time: 695ms
memory: 373836kb
Test #40:
score: 0
Accepted
time: 700ms
memory: 374180kb
Test #41:
score: 0
Accepted
time: 744ms
memory: 373888kb
Test #42:
score: 0
Accepted
time: 694ms
memory: 373264kb
Test #43:
score: 0
Accepted
time: 686ms
memory: 374840kb
Test #44:
score: 0
Accepted
time: 722ms
memory: 373092kb
Test #45:
score: 0
Accepted
time: 654ms
memory: 374096kb
Test #46:
score: 0
Accepted
time: 714ms
memory: 373304kb
Test #47:
score: 0
Accepted
time: 741ms
memory: 374560kb
Test #48:
score: 0
Accepted
time: 705ms
memory: 373488kb
Test #49:
score: 0
Accepted
time: 731ms
memory: 374720kb
Test #50:
score: 0
Accepted
time: 699ms
memory: 374584kb
Test #51:
score: 0
Accepted
time: 731ms
memory: 373356kb
Test #52:
score: 0
Accepted
time: 735ms
memory: 373712kb
Test #53:
score: 0
Accepted
time: 713ms
memory: 374232kb
Test #54:
score: 0
Accepted
time: 724ms
memory: 373492kb
Test #55:
score: 0
Accepted
time: 750ms
memory: 373648kb