QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#520154 | #148. Brperm | 369Pai | 100 ✓ | 167ms | 230456kb | C++20 | 1.3kb | 2024-08-15 11:09:59 | 2024-08-15 11:09:59 |
Judging History
answer
#include "brperm.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 5e5 + 5 , LG = 20 , P = 131;
int n , t; ull p[LG] = {P} , f[LG][N] , h[LG][N] , iv[LG][N];
ull Qpow(ull x , ull p = (1llu << 63) - 1)
{
ull res = 1;
for(; p ; p >>= 1 , x = x * x)
if(p & 1)res = x * res;
return res;
}
ull Get(int k , int l , int r){return (h[k][r] - h[k][l - 1]) * iv[t - k][l - 1];}
void init(int n, const char s[]) {
::n = n , t = __lg(n);
for(int i = 1 ; i <= t ; i++)
p[i] = p[i - 1] * p[i - 1];
for(int i = 0 ; i <= t ; i++)
{
iv[i][0] = 1;
iv[i][1] = Qpow(p[i]);
for(int j = 2 ; j <= n ; j++)
iv[i][j] = iv[i][j - 1] * iv[i][1];
}
for(int i = 1 ; i <= n ; i++)f[0][i] = s[i - 1];
for(int i = 1 ; i <= t ; i++)
for(int j = 1 ; j + (1 << i) - 1 <= n ; j++)
f[i][j] = f[i - 1][j] + p[t - i] * f[i - 1][j + (1 << (i - 1))];
for(int i = 0 ; i <= t ; i++)
{
ull pw = 1;
for(int j = 1 ; j <= n ; j++)
{
h[i][j] = h[i][j - 1] + s[j - 1] * pw;
pw = pw * p[t - i];
}
}
return;
}
int query(int l, int k)
{
int r = (++l) + (1 << k) - 1;
if(r > n)return 0;
return f[k][l] == Get(k , l , r);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 13
Accepted
Test #1:
score: 13
Accepted
time: 0ms
memory: 42752kb
input:
ykkubxafnylfriivjjqphltuagfkfcoigfcukuisdgufezomndodalbusgesraatkgnskdsiedfysodmsemmtjuoiezoaqljdodegogedjfpfwntljpgdhswtmqtwtpnbaawfumskuiwjodtsrlhblpunzqjkrzaakamjzyumkzfdjxwdkadgbwffjmldsfbhaltfnykbmvnxdkpfzsswpnmyyqpalsalaeqmqqivzqyhjgiiwfugmpxxsmkkgecuvrnlkujbyllhecpjsneluvsyckueeexhbtuhikfzuvw...
output:
0 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 1 0 1 1 1 1 0 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 1 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 1 1 0 1 1 0 0 0 0 1 0 0 1 1 1 1 1 0 ...
result:
ok 1000 lines
Test #2:
score: 13
Accepted
time: 0ms
memory: 42604kb
input:
qytnjgmxfvhrgflrfktkttxvrftktiffaimtwsuflrvflacgltptqwyhvtytpmtlcftxyudiogevzswhhzplvdrvjhvileplggptfgmgdvehzodzazxgmyzsdowekeldhyngdxaoidkjydlhyabgthtzyzdlwkovtmlfedeeketvdwypbxlplnqwldypolfrtzqmeaezhefeiekhsfykkikslcwehplfobxalbqioelvalobhnalvnilbibnloeinzjxcmbvltcrdvdcjrlbebjdecqlflejadfeizhvsylp...
output:
0 1 0 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 0 0 1 0 0 0 1 0 1 0 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0 0 1 1 0 1 0 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 1 0 0 1 1 0 1 1 0 ...
result:
ok 1000 lines
Subtask #2:
score: 37
Accepted
Dependency #1:
100%
Accepted
Test #3:
score: 37
Accepted
time: 24ms
memory: 114372kb
input:
rsufzafbpxjkrmubvscneqiybldroqajxbazpqccqthkdqgsiukjicklhvisezmlrkofmplwgrpanulsknxxzuiovforkarjqwfqdsqmitupfumbsisykznbpvhvntpkfrzajusffhmopgxgrxtisguptwnkftwryxqzeifbyvrieczlfvpzfbxdpryejqmykjaehxmylarbpjgkxrumngzsmapsneinpczjoiaepikvgvvpnsoexvwnfimqarnmxnkcsfddmhgfylrepscljvyrnoprauklhbqxbslivtsr...
output:
0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 0 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 1 0 1 0 0 1 1 1 1 1 1 1 1 0 0 1 0 0 1 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 1 1 ...
result:
ok 100000 lines
Test #4:
score: 37
Accepted
time: 39ms
memory: 120568kb
input:
gqecxoexyofzehscrttbsvrrffnonisgyqzjraxdeesuffbylrmfutnfwezoazvwdjyekgxtivifkuzknisgzkwdtzbzcetbjilaanpotjzhmbkjmjmrrkaglhqcgrbrlzlzdqujehrzqhiyzkgixcxxchqjvftjlrzwiwamynidjiccupftpmfojtfwyuiazwhwvdgavibfjzbmfmbrafkhdixqztgsckzkoexacdbabhkgblulpbkvvbsmjnftnelwajkwlktjsmpzrrujjkfjlvdripsclprqcxrdzood...
output:
1 0 1 1 1 0 0 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 0 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 1 1 0 0 0 ...
result:
ok 100000 lines
Test #5:
score: 37
Accepted
time: 24ms
memory: 116512kb
input:
wszieltjkpvmfwmgjtxjzamhomyinzeejaslmbhiphzlkjgdgkjmnskyfdwumsnkdlesdslhejnrqvszyjvnrbjgvmyfyhxaeilsyhwwgnldnqzvgcdvaxlqcoitsiwwzmhchufvbqlitqiewntfkvufhkvnpcqmrehqdahbcxeuzwcjvkkptiymqpbakjeyekhupyaehjekeekcuiyczbwbnrrfzqwgapqjaqpzedeeayswxhmginefjozxkaefitrbkxwoczmvjuqyuxlqnvbojqrwvtsncvbukbcyneyp...
output:
0 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 0 1 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 0 0 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 ...
result:
ok 100000 lines
Subtask #3:
score: 17
Accepted
Test #6:
score: 17
Accepted
time: 122ms
memory: 229284kb
input:
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb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 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0 0 1 ...
result:
ok 500000 lines
Subtask #4:
score: 33
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #8:
score: 33
Accepted
time: 133ms
memory: 227260kb
input:
aectkyaaxcoazrdbtqsxfittdcpjpcgfnbsjcvrwzvklcmhfuivgagtbctipbkkyvrmcvwbfeshuwchffsuqvttnjpwzzxpmloynuhjvcbruvaoxrynquictutfhwdpttsigbzpehkwqxuukvywmtnsdblopchhqcvurhductjjvhcwewxnatbvekznxflmjfzqmtbqprytwvwoicxmrmmmqudscszchdpdlltzuwmrfmcpsclwhzgdermgaqhjjoqokvktsbynlsjjhkjwcixejshokbzlukohcmcexwhqq...
output:
0 0 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 1 1 1 ...
result:
ok 500000 lines
Test #9:
score: 33
Accepted
time: 115ms
memory: 230456kb
input:
aybuckskrrjbuirvnoziazajvpppztxailyqsrfcdzhbgjsilbpvzdzgonheobuwuskisxgoytqwhfprimszzqyffpzrcxluqyynaeqthnjmtmdmahzqafwxxglfkzjmdsgfyrmywhwnlosqxxzhbirvotibywrlhcvybwbybdlwzcpfrbpneevxgdzqolcdlnpznejeukxxeojdykbynbklqxohlfakkuhvwnsojbfkahpntkafuzckumqdhoxpntmfzrtdbxwbgtevmuwwurclheowowpmmrsttvdwxxiz...
output:
0 0 1 1 1 1 0 0 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 1 1 0 1 ...
result:
ok 500000 lines
Test #10:
score: 33
Accepted
time: 129ms
memory: 228068kb
input:
lpbzamryfcfiqhyouztxcmcyevavzbdgomejlgzlnxzamwcphtgrcmpuzgasqynqpbicrhohrpfdtffxaaqbxzuelwegrzjxooqvvhaicokzqclxrpymfxmafpxcwwjcquqoqvlabbnwyixrojrnakcakiatavdxulmsgogvjwkpqnbiomujtfkrmnuxzonljusbvlhxgrpxcrcmckjqmswdmnxikfdrrkbkxkumdyvmqrlnsnvcgwxqwkyyyukfxhzyqyghtcsfijietgucpmphpnumjobylhiylfrhjyqh...
output:
0 1 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 0 0 0 1 1 1 1 0 1 0 1 0 0 1 1 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 1 0 1 1 1 0 1 1 0 0 1 0 0 1 0 0 0 1 0 1 0 ...
result:
ok 500000 lines