QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#615396#6832. Last Warning of the Competition Finance Officerucup-team1001WA 812ms18792kbC++202.6kb2024-10-05 18:25:522024-10-05 18:25:57

Judging History

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

  • [2024-10-05 18:25:57]
  • 评测
  • 测评结果:WA
  • 用时:812ms
  • 内存:18792kb
  • [2024-10-05 18:25:52]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

namespace strhash {
    using u64 = uint64_t;
    mt19937_64 rng(random_device{}());
    const int base = 135 + rng() % 114514;
    constexpr int p1 = 1'0000'0000'7, p2 = 1'0000'0000'9;
    constexpr unsigned msk32 = ~(0u);

    vector<u64> pw1{1}, pw2{1};

    class StringHash {
        vector<u64> h;
        int n;
    public:
        StringHash(const string &s) : n(s.length()) {
            int old_size = pw1.size();
            if (old_size < n + 1) {
                pw1.resize(2 * n + 1, 1), pw2.resize(2 * n + 1, 1);
                for (int i = old_size; i <= 2 * n; i++) {
                    pw1[i] = pw1[i - 1] * base % p1;
                    pw2[i] = pw2[i - 1] * base % p2;
                }
            }
            u64 now1 = 0, now2 = 0;
            h.resize(n + 1, 0);
            for (int i = n - 1; i >= 0; i--) {
                now1 = (now1 * base + s[i]) % p1;
                now2 = (now2 * base + s[i]) % p2;
                h[i] = (now1 << 32) | now2;
            }
        }
        u64 get(int l, int r) {
            int len = r - l;
            u64 l1 = h[l] >> 32, r1 = h[r] >> 32;
            u64 l2 = h[l] & msk32, r2 = h[r] & msk32;
            u64 res1 = (l1 - r1 * pw1[len] % p1 + p1) % p1;
            u64 res2 = (l2 - r2 * pw2[len] % p2 + p2) % p2;
            return (res1 << 32) | res2;
        }
    };

}  // namespace strhash
using namespace strhash;
#define int ll
#define ll unsigned long long

const int mod = 998244353;
#define irep(i,l,r) for(int i = l; i <= r; ++ i)

vector<int>stlen;

ll f[1000000 + 7] = {1};
signed main(){
    ios::sync_with_stdio(false), cin.tie(0);
    string s;
    cin >> s;
    int n;
    cin >> n;
    vector<ll>v(n);
    vector<string>a(n);
    map<ll, int>h;
    irep(i, 0, n - 1){
        cin >> a[i] >> v[i];
        stlen.push_back(a[i].length());
    }
    sort(stlen.begin(), stlen.end());
    stlen.erase(unique(stlen.begin(), stlen.end()), stlen.end());
    StringHash H(s);
    irep(i, 0, n - 1){
        StringHash T(a[i]);
        h[T.get(0, a[i].length())] = i;
    }
//    irep(i, 0, n)f[i] = 1;
int m = s.length();
    irep(i, 0, m - 1){
        f[i + 1] += f[i];
        for(int len : stlen){
            int j = i + len;
            if(j > m)continue;
            auto it = h.find(H.get(i, j));
            if(it != h.end()){
                int idx = it->second;
                f[j] += f[i] * v[idx] % mod;
                f[j] %= mod;
            }
        }
        f[i] %= mod;
    }
    irep(i, 1, m){
        cout << f[i] % mod << ' ';
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

input:

ababa
2
aba 2
ba 3

output:

1 1 6 6 26 

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

qfmyqqfmyqqfmyq
2
qfmyq 111111
myqq 404968002

output:

1 1 1 1 111112 405079114 405079114 405079114 405079114 771912310 239058268 239058268 239058268 239058268 31169271 

result:

ok 15 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

wwwsoupunetcom
2
money 999999
soup 998244352

output:

1 1 1 1 1 1 0 0 0 0 0 0 0 0 

result:

ok 14 tokens

Test #4:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

azero
1
a 998244352

output:

0 0 0 0 0 

result:

ok 5 tokens

Test #5:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

aiiaiaia
2
aiia 5
iiii 2

output:

1 1 1 6 6 6 6 6 

result:

ok 8 tokens

Test #6:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

lnvnnvlvvnnnlln
3
vllln 7
nlnlvlvnn 7
n 2

output:

1 3 3 9 27 27 27 27 27 81 243 729 729 729 2187 

result:

ok 15 tokens

Test #7:

score: 0
Accepted
time: 2ms
memory: 4112kb

input:

ewxwxwxewexxxeexexeeexeeeexxxexwwxeewxexxexwxexwxewwwewxxwwwxeexxxxweeweeewwwwxxewewwxeexxxeeewwwxeewexxxexwwwewxeweeewwwxeewexewxwweewxexewxwxxxwxxwwewewwwexxwwweexwexxwxewxwexewexwexweexwxwwxwxwweewexxxxewwwxxexwwxewxewwwwxwwxxexwwwxwexwxeeeexwwwxwxxwxxexexwewwewewewexwexwwewxexwxxxwxewexweeeexwxe...

output:

1 4 32 128 1024 4096 32768 32768 131072 131072 1048576 8388608 67108864 67108864 67108864 536870912 209715199 679477239 58720241 58720241 58720241 469761928 58719985 58719985 58719985 58719985 469759880 763345981 117301730 117301730 938413840 758922301 40956145 327649160 327649160 327649160 31235228...

result:

ok 3999 tokens

Test #8:

score: 0
Accepted
time: 22ms
memory: 13396kb

input:

fsednrpubwbzxugoznffuvabwcsfleuuzysyguzpaebygywmspikmrchjrqwnsuajulhztddbhsettkfgrwffianmurgmbagmmnxeqijppgvvaqusszvkzdtftzrhwaotrwnwxpsexqjrpinojpmrucnuiuxruyuatuttdapxunwrqgmwpxafnuhyyhebsjffodwazlbsodbbvitqemftxlbrlzataluvgghhabfvjgtlymetljlwrdavdtchhqlvgcwpzecnxhwhrhntscqzvskfgoqtvfcimpzzvwxjoey...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 200000 tokens

Test #9:

score: 0
Accepted
time: 812ms
memory: 13428kb

input:

mqmqqqqmmmqmmmmqmqmqqmqmmqqqqqmmmqqqqmmqmqqqqqmqqmmqqmqqqqqqqmqmqmqmqmqqqqmmmmqmqmmqmqqqmmmqqqmmqmqmqmqmmmqqqqqqmqqmqmqqmqmmqmmqmqmmmqmmmmqmmmqqqmmqmmqmqqmqqqqqmqqmmqqqmqmqmmmqmmmmqmqqqqqqmmmqqqmmqmmmqqmqqmqqmqmqqmqmmmmmqqqqqmmmmqqqmmqqqqqmmqqmmqmqqqqqmqqmqqqmmmqmmmmqmqqmqqqqmqmmqqqmqmqqmmqmmqqqqmqq...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 200000 tokens

Test #10:

score: 0
Accepted
time: 70ms
memory: 13500kb

input:

zttztzzttzztzttztzztzttzzttztzzttzztzttzzttztzztzttztzzttzztzttztzztzttzzttztzztzttztzzttzztzttzzttztzzttzztzttztzztzttzzttztzzttzztzttzzttztzztzttztzzttzztzttzzttztzzttzztzttztzztzttzzttztzztzttztzzttzztzttztzztzttzzttztzzttzztzttzzttztzztzttztzzttzztzttztzztzttzzttztzztzttztzzttzztzttzzttztzzttzzt...

output:

1 946852958 430426865 779623793 317175025 921269781 921269781 873292193 464703273 21110678 21110678 443492495 217360625 376615661 834805190 728273869 746753500 641883107 641883107 927443781 511400149 634152015 218432797 475037110 475037110 740681916 415962099 39102848 826166045 290244563 290244563 6...

result:

ok 200000 tokens

Test #11:

score: 0
Accepted
time: 81ms
memory: 13656kb

input:

laalallaallalaalallalaallaalallaallalaallaalallalaalallaallalaalallalaallaalallalaalallaallalaallaalallaallalaalallalaallaalallaallalaallaalallalaalallaallalaallaalallaallalaalallalaallaalallalaalallaallalaalallalaallaalallaallalaallaalallalaalallaallalaalallalaallaalallalaalallaallalaallaalallaalla...

output:

1 934455506 322488340 552880764 136660401 126582157 126582157 890356082 144302821 42980792 42980792 54135957 639137805 968604669 473756230 586383491 217293859 408406383 408406383 771064849 765615321 835238149 91405243 174694426 174694426 447739686 804931548 178954746 572312220 727117256 727117256 78...

result:

ok 200000 tokens

Test #12:

score: 0
Accepted
time: 478ms
memory: 13008kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

554519100 685528937 59731397 943045143 506743396 2596363 929304203 342760279 967393347 295097106 350728553 566442496 971387117 324028329 694396672 647702792 738794058 797361219 505246916 345768455 132354030 15153563 158306119 959041537 838172393 3267578 194076496 989266686 783308360 78645732 8128249...

result:

ok 200000 tokens

Test #13:

score: 0
Accepted
time: 545ms
memory: 12936kb

input:

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyykyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

output:

341462633 771808453 717211977 695599585 820409487 843432666 76987829 471955795 633297174 73416323 304380459 529276995 930584594 868681388 777168451 118058274 875788517 357086618 846760177 818022536 764089388 869023280 89335013 473253220 632960494 62919870 141966236 55445344 707773243 410582973 60296...

result:

ok 200000 tokens

Test #14:

score: 0
Accepted
time: 539ms
memory: 12920kb

input:

iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiviiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...

output:

477382236 305693684 303437823 41175457 417466061 338172114 950582575 421607664 695401531 344083825 353106743 806144665 698415493 827300486 236479007 712923777 470879251 268655623 165987011 380213770 812331263 97406453 855262851 528466926 581848917 211238619 611494601 468131872 914712919 437582368 25...

result:

ok 200000 tokens

Test #15:

score: 0
Accepted
time: 112ms
memory: 18792kb

input:

qgzrxiwbvezgfnqlartwoyzixilgyqxqudeezvzaybcjjreumxtwtatneltiphuzulgtbyllwordwovvnpcctbppdipvnucnmivetootdmfomvjuwqfyyrvhqwcqewaamfqgnioolkchwppctuptakcznautdeglosffjbtzpzkebxwlzwhnvqxabxtrkwuiptavsamggfdfjjhyuwkffpcoyckffbtnhiktxzdjkqfgofclvjnlwlndtgwmmjgnseprdmmffjblgshehxlxvcrfislejgaotyccsiyhntby...

output:

869349390 632477731 736183817 217596475 508870766 795333566 40461514 900043802 129918483 852739510 244498925 474928728 14807545 683067573 989913540 500786909 222881437 867645664 96123332 219727173 310943596 207781709 868078419 238100102 1750086 112212097 716031351 121940181 165751224 368856550 49377...

result:

ok 200000 tokens

Test #16:

score: 0
Accepted
time: 239ms
memory: 14480kb

input:

xxyyyxxyxxyyyxxyxxxxxyyyyxyyxxyxyxyyxyxyyyxyxyxyyxxxxyxxyxyxxxxxyxyyyxyxyxyxxxyyyxxyyyxxyxxxyxyyxxxyxyyxyxyxyyxxyxyyxxyyyxxyyxxyxyxxxxxyxyyyxxxxxyxxyyyxxyyyxyxxxxxxyyyxxyxxyxxyyyxxxyyxyyyyyyyxyyxyyyxxyyxxyxyxyxyxyxyxxxyxxyyxxyxyyxyxxyyxxxyyxxyxyyxyyxyyxxyxyxxyyxxxyyyyyxyyyxxxxxxyxxxyxxxxxyxxyxyyyxyy...

output:

927915910 543169985 854987137 6757731 386781336 66279301 951487175 62832555 778596363 8075217 422418920 618489020 816644900 331878171 133328371 850861186 356748007 313274483 397194809 396573643 524718725 711395033 172036128 37122093 285311752 980769745 144009495 419327162 850775228 80018721 63875356...

result:

ok 200000 tokens

Test #17:

score: 0
Accepted
time: 19ms
memory: 13856kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

562294349 750802095 392954316 274382602 818835208 132836758 165096970 51978744 181208435 830410775 428921622 212425350 965280112 351466609 777697055 558404563 352067784 601212034 835946767 136851634 668590958 852565630 723090990 398244977 132763518 297759225 594970302 590045938 705710538 464282883 1...

result:

ok 200000 tokens

Test #18:

score: -100
Wrong Answer
time: 64ms
memory: 18280kb

input:

uuddzkxquotwmzmtmmzlmmhisjfluryncjixegahunrzkxxsstkujjiyrazhkxwksmwohamflxklpkgwkpztycaiduhmhvntbbyutfvsnwzfnaugilabbeybvjedqfnrpoarkunydndmvupezhrvsrbbltcfyhhbegavtivwyhcvcssihpnqfroyoxpzizzucyvftznxvqyfxbwamxugwdvypbzhtifoluosahojyptzoqgtcdmblhcnrzhwildwiskmfcfdkoxgdzquoedballvbqlcytkfjvsjtmdzvlxk...

output:

1 1 1 1 1 1 1 258518992 258518992 258518992 258518992 258518992 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 618797806 259392582 259392582 259392582 259392582 259392582 259392582 41189292 41189292 41189292 41189292 41189292 41189292 41189292 411...

result:

wrong answer 422nd words differ - expected: '364691282', found: '430883725'