QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89008#4062. 军队james1BadCreeper15 3034ms16416kbC++142.6kb2023-03-18 10:56:462023-03-18 10:56:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-18 10:56:49]
  • 评测
  • 测评结果:15
  • 用时:3034ms
  • 内存:16416kb
  • [2023-03-18 10:56:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64; 
const int BLOCK_SIZE = 500; 

int n, q, C, LL, RR; 
int a[250005], c[250005], aa[250005], cc[250005];
int L[505], R[505], vis[250005], cnt[250005]; 
i64 ans[250005]; 
struct Query {
    int op, l, r, x, y;
} Q[250005]; 

int main(void) {
    scanf("%d%d%d", &n, &q, &C); int t = (n - 1) / BLOCK_SIZE + 1; 
    for (int i = 1; i <= t; ++i) L[i] = R[i - 1] + 1, R[i] = i * BLOCK_SIZE; R[t] = n; 
    for (int i = 1; i <= n; ++i) scanf("%d", a + i); 
    for (int i = 1; i <= n; ++i) scanf("%d", c + i), cc[i] = i; 
    for (int i = 1; i <= q; ++i) {
        scanf("%d%d%d", &Q[i].op, &Q[i].l, &Q[i].r); 
        if (Q[i].op != 3) scanf("%d%d", &Q[i].x, &Q[i].y); 
    }
    for (int k = 1; k <= t; ++k) {
        LL = L[k], RR = R[k]; i64 res = 0;
        memset(cnt, 0, sizeof cnt); 
        for (int i = LL; i <= RR; ++i) ++cnt[c[i]], res += a[i]; 
        for (int i = 1; i <= q; ++i) {
            int op = Q[i].op, l = Q[i].l, r = Q[i].r, x = Q[i].x, y = Q[i].y;
            if (r < LL || l > RR) continue; 
            if (l <= LL && RR <= r) {
                if (op == 1) cnt[y] += cnt[x], cnt[x] = 0; 
                else if (op == 2) res += 1ll * cnt[x] * y; 
                else ans[i] += res; 
            } else {
                int bl = max(l, LL), br = min(r, RR); vis[i] = k; 
                vector<int> bin; 
                for (int j = i - 1; j >= 1; --j) {
                    if (vis[j] == k) break; vis[j] = k; 
                    if (Q[j].r < LL || Q[j].l > RR) continue; 
                    if (Q[j].op == 1) {
                        aa[Q[j].x] = aa[Q[j].y]; // x 颜色改成 y,x 
                        cc[Q[j].x] = cc[Q[j].y]; 
                    } else if (Q[j].op == 2) {
                        aa[Q[j].x] += Q[j].y; 
                    }
                    bin.push_back(Q[j].x); 
                }
                for (int j = bl; j <= br; ++j) a[j] += aa[c[j]], c[j] = cc[c[j]]; 
                for (int x : bin) aa[x] = 0, cc[x] = x; 
                if (op == 1) {
                    for (int j = bl; j <= br; ++j)
                        if (c[j] == x) c[j] = y, --cnt[x], ++cnt[y]; 
                } else if (op == 2) {
                    for (int j = bl; j <= br; ++j)
                        if (c[j] == x) a[j] += y, ans[i] += y; 
                } else {
                    for (int j = bl; j <= br; ++j)
                        ans[i] += a[j]; 
                }
            }
        }
    }
    for (int i = 1; i <= q; ++i) if (Q[i].op == 3) printf("%lld\n", ans[i]); 
    return 0; 
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 4552kb

input:

20 20 20
30243234 8075384 84797560 57803992 42319867 50261707 15353170 87049722 52811301 29102071 30384516 10767047 91603720 58528416 15628343 44318195 29714732 36726699 52647799 81762999
20 9 17 6 19 17 16 9 9 16 9 16 20 7 7 6 9 16 20 17
1 7 11 15 8
2 12 18 20 79118894
2 10 10 17 20830614
2 5 13 16...

output:

146267200
355638999
150385566
1049277575
1266631961

result:

wrong answer 5th lines differ - expected: '1322069997', found: '1266631961'

Test #2:

score: 0
Wrong Answer
time: 2ms
memory: 4596kb

input:

50 50 50
47705292 79259033 79303307 38844616 66412531 43420151 3364357 14597117 99004891 68901351 32135604 39554351 34639440 5387566 19433342 8914638 26472946 66711427 5636444 46153851 87137205 45506835 43469019 2374029 29476960 27618304 3604894 59237007 67952398 37510365 29024217 22096832 59227823 ...

output:

1586177684
1415635369
1165188063
3296140209
3369165108
3871595893
3078084878
2414792814
3001063843
3293036492
3954402483
1613339946
4368823965
3758773712
4839676430

result:

wrong answer 5th lines differ - expected: '3438314155', found: '3369165108'

Test #3:

score: 5
Accepted
time: 3ms
memory: 4548kb

input:

300 300 300
29243820 83772064 39738037 44878087 31623526 23123134 97305631 33867225 7714687 2676701 30321688 34832789 23015521 12138789 74684400 18275423 76346088 86035029 28062383 69725742 8835044 36317245 9034384 78372175 30264218 32833347 74592384 85439456 9739844 66193122 73529763 87821398 80473...

output:

10118808399
2437328749
6894566899
2382531372
10464596442
8679691771
5910918799
2070123918
4025677477
14258513547
7745443874
3011115333
5024377251
9574097996
9771511985
9593945633
15226211206
12369894829
14571163834
13418269546
12404574705
870236152
6929295272
10925135938
3239802087
3620123601
101537...

result:

ok 111 lines

Test #4:

score: 0
Wrong Answer
time: 11ms
memory: 4788kb

input:

5000 5000 5000
26271334 17740608 6429725 18194643 48835514 48736874 75645934 91140616 18374829 76432627 40519421 35670186 41356817 33934613 49204374 60525054 70544459 92654784 37541847 46656829 1794774 57126165 9249076 63842067 66676926 68366827 79346934 81117986 55171878 1849933 98009783 86222973 8...

output:

191906686362
124092650316
93554254882
179070074570
237417960913
170946816115
77188675368
225680273250
188335402953
189174298223
77838815873
227919712871
73931978749
231602004793
168236648191
195423150550
5864568809
198395602692
115507556016
242295283351
116334411605
134971549433
235807065328
1421438...

result:

wrong answer 4th lines differ - expected: '179094715357', found: '179070074570'

Test #5:

score: 0
Wrong Answer
time: 508ms
memory: 8812kb

input:

100000 100000 10
87634691 9238657 78446718 46909652 19480456 92746571 71134242 35370645 88391946 96011588 10281496 38515411 13269227 95849707 75639492 12043745 90981041 93719171 28852973 83236884 67074438 56437908 73606720 2264644 15796665 47645544 73017549 17796174 48048699 38331023 79004296 113483...

output:

1469785330361
6971690625739
4514351274498
3894996224288
288865749911
4131683517578
8547357861389
8292112405521
6917056613011
1088002407774
11063911717845
12903575870014
2509229221904
11515824703204
11376552974868
11272325587450
6235341681893
9074379624830
116724428323
13092478986763
15925942749206
1...

result:

wrong answer 2nd lines differ - expected: '7020597626075', found: '6971690625739'

Test #6:

score: 0
Wrong Answer
time: 1107ms
memory: 11140kb

input:

150000 150000 10
45699249 74527354 69158258 66810715 36123128 20997399 18809641 59871912 96656349 80147667 7540841 85964516 30759033 83169693 76371491 74234731 50443576 86328539 34204892 17289803 76716632 96525028 18959662 38159303 67108461 43065478 79616583 68829397 54491360 20760704 37585000 13987...

output:

14215100284726
10888595622887
28916777616299
30097341567664
30363782994057
39736639216019
30044552933232
30039374748074
30866571739248
53687855709525
11907355157454
60269652942263
14218167590741
19529955092446
50084119362791
30277480352018
81449560403360
87396729904702
33800202162510
72281195287655
...

result:

wrong answer 1st lines differ - expected: '14259860173368', found: '14215100284726'

Test #7:

score: 0
Wrong Answer
time: 1786ms
memory: 13292kb

input:

200000 200000 10
90783632 43461822 44741311 37815039 58121601 21011778 83299478 20257621 19546636 29642908 66420193 12207707 41441773 86786355 78742526 62600685 20847940 97816438 16899567 23797290 51190806 59663700 95431386 47833589 93718987 69960644 94545546 47867510 35120302 77773119 13773547 1880...

output:

17932333828326
23041309833528
27627151536936
34615817298193
4823257211231
33846712985856
5840674685283
39268845502845
8255481369975
36979665317724
50988795946762
77693552048113
74298693421931
35253315170473
36156007146331
18448197573057
75632558119975
70721955983086
110022369797569
115572494840649
1...

result:

wrong answer 1st lines differ - expected: '18002902424490', found: '17932333828326'

Test #8:

score: 0
Wrong Answer
time: 2719ms
memory: 15316kb

input:

250000 250000 10
2210222 82935278 19232326 14669930 89812300 35248803 33512605 20033126 77398113 2025289 50924947 16057035 39971776 56952249 38814990 13637331 5595007 85744047 17771895 6626014 92748923 86914124 2193211 93573612 45974481 73034388 90751307 58292005 85309542 95106030 30663836 31643473 ...

output:

1834863435460
29039593537331
19388678903104
28077443733875
38032084973408
29684007979011
2972007354179
41218576109660
42930641202275
33945463810940
29842302525969
6229195331065
37165552687692
12903037640684
40270268151415
36731534864687
26203877959744
36189407665426
25909268957233
48204286005993
346...

result:

wrong answer 2nd lines differ - expected: '29084657808792', found: '29039593537331'

Test #9:

score: 5
Accepted
time: 517ms
memory: 10448kb

input:

150000 150000 150000
99577522 32012715 68102898 98506256 89365247 71251760 36482614 50882065 3330101 22229696 37660026 51953045 75927882 92198075 61877715 90768880 95438740 21226632 6348028 73090230 73617489 21276430 91320531 39542341 24895777 81863227 51583706 15794235 52344710 98399873 78384055 31...

output:

7510883542426
7510883542426
7510883542426
7510883542426
7513837599475
7513837599475
7513837599475
7513837599475
7515944738755
7515944738755
7515944738755
7515944738755
7518490597879
7522017070699
7522017070699
7522223287453
7522223287453
7522632925309
7522632925309
7522676523397
7522797670374
752279...

result:

ok 50152 lines

Test #10:

score: 5
Accepted
time: 1371ms
memory: 14392kb

input:

250000 250000 250000
56852995 78154998 60271318 10513775 75734822 72600566 5964612 89662045 23401119 59823512 53225375 99397044 3913649 58823943 16620194 61943977 7237680 84859682 3441374 3894884 27292424 34061563 68628278 57552770 35728564 1444697 36285025 91145620 75865799 63807285 73381996 478447...

output:

12487260051734
12489093561826
12490835706102
12490835706102
12490835706102
12491885996502
12493942958514
12493980590828
12493980590828
12493980590828
12493980590828
12493980590828
12493980590828
12493980590828
12493980590828
12493980590828
12494169853898
12497463121086
12498700847582
12500607395342
...

result:

ok 83011 lines

Test #11:

score: 0
Wrong Answer
time: 1120ms
memory: 11696kb

input:

150000 150000 150000
71802708 5110137 84478065 39272927 39616444 95839554 27563695 97784082 94614207 56950816 77293301 8669519 22508222 1363851 42748670 76957176 32467306 37586030 79121942 91831589 17912397 47122604 8320928 11597344 39111233 33453209 3637393 39717095 20337398 24764029 49752562 61482...

output:

5132746788195
4961697741242
4177609086733
4004616509157
7093357165669
5615325240534
4258139941063
3760313398139
5628980615411
2355421569862
3261502562778
5729695008815
4938744711910
1099687962772
6048800727210
4545915038008
4715348349242
5765144382583
4612034365663
3470540912177
3464413359163
502041...

result:

wrong answer 48th lines differ - expected: '5097153881604', found: '5097119633787'

Test #12:

score: 0
Wrong Answer
time: 1899ms
memory: 14004kb

input:

200000 200000 200000
70794361 87738164 85865207 44870300 69463701 15394658 90165208 77525961 8406227 29152852 54558684 69930905 33705346 5676378 80429758 41189333 35636071 77140314 43205099 44610846 90528315 11145295 77686535 15302504 29303339 66820293 79629672 25248122 38825046 637535 97066905 8225...

output:

7802105574677
156110705048
5554206990014
7762642801066
6763801653234
7696733459062
6138865223830
6898379054241
7452504684192
3688969737875
3075521763935
2540187376098
4340261704360
1981037180191
1396001481493
5310747653825
4827212150172
7674936330978
2820388615237
4634531540970
3217470748680
6531451...

result:

wrong answer 30th lines differ - expected: '6463787840651', found: '6463609151984'

Test #13:

score: 0
Wrong Answer
time: 2909ms
memory: 16360kb

input:

250000 250000 250000
44897725 4685316 80312977 66416370 37045221 53652540 64608893 38736402 94315253 27113025 23724054 83600804 944234 53789915 38578705 56016955 32943062 15741957 20442492 32512985 51216478 91487596 17080118 85030264 26512956 84765684 34899570 55496069 77376318 32442931 67761720 667...

output:

7411553663025
8180187744843
5929716569377
9659991508141
7355269616549
7050415802748
10724644181202
7777472591901
9376332947410
3582538932610
10256354338066
7713521925846
9888064895489
6256038292188
11730686228782
11039452845716
10094055410970
7576105867469
8385715199583
3244000097042
5648175457135
7...

result:

wrong answer 11th lines differ - expected: '10256445536363', found: '10256354338066'

Test #14:

score: 0
Wrong Answer
time: 1052ms
memory: 11600kb

input:

150000 150000 150000
17900067 78932069 18293989 38405873 94155098 3735350 14962051 80058300 51104407 36859282 78213107 87943521 78061902 12815549 49062192 60270270 38831524 28451023 70262060 45754565 22829045 6898739 79654475 93991932 48499534 96187176 5073893 30012155 47124979 1138755 40182729 3119...

output:

3057375374835
3748965736123
1180792816149
3880142354039
5967759675489
6223761905886
3754620352398
4791315184295
5951183730250
5679090877190
6145337401026
6166077200752
6106690484946
5554931279612
2185551264711
5164742578932
3977584644384
6415258342433
5674199353856
5364422009931
4284142643046
198135...

result:

wrong answer 23rd lines differ - expected: '5363184938700', found: '5363033329802'

Test #15:

score: 0
Wrong Answer
time: 2766ms
memory: 16288kb

input:

250000 250000 250000
54027461 319223 99031875 95715925 19269878 9776579 86722408 70778481 46207527 21433896 15972484 48270769 54399383 94090870 40934533 68860522 58931716 50002726 83304991 6498900 38392886 22829136 43422537 57625355 93122677 60990771 7681213 10369168 36288269 76400049 93782396 89050...

output:

11126310640157
10776830210942
8462741667846
9218855579962
7312978082589
10995795714050
7290149808881
7500793363224
5675690763754
6492306079862
7958214006769
3262111526636
9266476195338
6058715801558
9411089111726
8712689135685
4317683926448
9424138231941
4543713407230
6310877400856
8378528741710
118...

result:

wrong answer 66th lines differ - expected: '3073799107909', found: '3073758577592'

Test #16:

score: 0
Wrong Answer
time: 557ms
memory: 9240kb

input:

100000 100000 100000
18898905 78786873 62376741 4477798 86371893 33332061 22853839 88697226 8346050 82304677 92659257 38144035 45376852 98616560 70250484 87325787 39947990 52638546 90256867 45437902 16073925 36472208 33963197 63849229 22670771 48369830 26539662 95533595 20956869 75274561 21941302 56...

output:

2272439975914
2440312306961
3338485073739
3526499482696
3964169569143
4683326821176
4533104405038
1183818176487
4463776730677
1882352020051
1493031420039
1917564568826
498467669843
4349364001240
4264544960593
2747084983220
3851971850844
4301057757796
4799217694044
2293677158822
4017167920316
1205784...

result:

wrong answer 2nd lines differ - expected: '2440353606546', found: '2440312306961'

Test #17:

score: 0
Wrong Answer
time: 1149ms
memory: 11680kb

input:

150000 150000 150000
89588275 44632728 86932398 36253637 45602569 26277832 73429980 96226120 86788418 32778562 60499661 85034265 71351994 34724593 35634789 83749438 65284095 85895575 94452349 33514960 3687379 83242310 79248481 78700412 47282605 6032614 76254291 44896517 77405497 87006899 93335302 94...

output:

5520537336026
4552896130563
5578241957103
3146470164250
5780826546060
4830791365826
3392685202764
5047514311620
7223564798073
4928665116648
6452046931930
3467679794989
6079975154830
4222983883010
4385517592346
3986806035303
4702041405965
4274478871340
6539569754472
644997870022
5489340867831
4468254...

result:

wrong answer 3rd lines differ - expected: '5578258553292', found: '5578241957103'

Test #18:

score: 0
Wrong Answer
time: 1881ms
memory: 13888kb

input:

200000 200000 200000
34177734 63114232 26119387 45933218 72578491 30192428 62814020 63726812 56098996 22585530 79088184 44653118 61283522 72228938 3107103 32127065 65837640 77771769 31178231 98078838 65705853 820439 74419154 32800270 36510445 25594474 99575894 93386063 68899064 95508265 30558267 964...

output:

4664348513880
3220989921028
4889262943224
3407352473616
7765413232817
6342178583977
6707874966112
7789295974617
2253336441249
7910762626518
9031852417891
5295432363385
635257284428
2918513105215
3901045794704
4870860169454
2404035076199
2429599868780
553026648922
8327057187216
1015835280888
76763791...

result:

wrong answer 11th lines differ - expected: '9031859191992', found: '9031852417891'

Test #19:

score: 0
Wrong Answer
time: 2953ms
memory: 16416kb

input:

250000 250000 250000
24918897 46510289 11362908 40719901 62264984 82269214 866178 31088617 24468878 92482470 22397651 44766395 82312396 27004202 53218396 87268151 77640722 69497678 9228462 59465250 6368996 60740377 64567135 81629158 99173128 58871415 84209799 19835410 7117321 89557434 70296899 12252...

output:

156332409734
5607498008497
4777273903966
7101310075019
10140710241884
11030902510743
11190017843044
7993165457061
10899728612204
8119118076637
5560930749289
6950597562043
9259019603558
6754184604324
8989396603717
11385863008665
7516439124645
8582428028764
10293689056829
6353684192232
10577941094352
...

result:

wrong answer 30th lines differ - expected: '6254833626730', found: '6254802438962'

Test #20:

score: 0
Wrong Answer
time: 3034ms
memory: 16304kb

input:

250000 250000 250000
85120612 9932286 61758975 8816091 79552272 25448018 90337103 42864270 64745010 3965612 20190114 27357072 30057458 74279926 11726860 72053959 71429613 94011053 25350994 38004713 78859443 91088995 91943536 36283906 89222730 79017534 98580756 7338994 49076137 51515254 10348064 8942...

output:

9915602446176
9617754106292
9507151022779
9328134174983
11539013748125
9107820167461
10871934873296
9055116146774
11326159291174
5918512316988
7934317773804
10751448551585
12307509234385
10932235500295
967189171778
9109715370229
8961071345061
5194191783433
9511521424509
10582435698503
11201998431924...

result:

wrong answer 59th lines differ - expected: '7933396589078', found: '7933383106717'