QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#89105#4062. 军队james1BadCreeper45 3137ms16440kbC++142.6kb2023-03-19 01:19:512023-03-19 01:19:53

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-19 01:19:53]
  • 评测
  • 测评结果:45
  • 用时:3137ms
  • 内存:16440kb
  • [2023-03-19 01:19:51]
  • 提交

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; 
                    if (Q[j].r < LL || Q[j].l > RR) continue; 
                    vis[j] = k; 
                    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 = LL; j <= RR; ++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, res += 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; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
1322069997

result:

ok 5 lines

Test #2:

score: 5
Accepted
time: 2ms
memory: 4568kb

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
3438314155
3940744940
3078084878
2414792814
3001063843
3293036492
4023551530
1613339946
4437973012
3758773712
4839676430

result:

ok 15 lines

Test #3:

score: 5
Accepted
time: 0ms
memory: 4580kb

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: 12ms
memory: 4776kb

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
179094715357
237698407160
171134530204
77351748670
225960719497
188615849200
189362012312
78001889175
228204459631
74095052051
231927978262
168904035170
195707532442
5864568809
198753194838
115822933013
242832653141
116590217065
135228080512
236344435118
1425793...

result:

wrong answer 1707th lines differ - expected: '658278722254', found: '653983754958'

Test #5:

score: 0
Wrong Answer
time: 519ms
memory: 8932kb

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
7020597626075
4561163614938
3896813649786
293085873525
4131683517578
8589714311865
8360296283837
6941829283179
1088002407774
11156868266329
13000594205500
2509229221904
11577963604684
11480554736556
11385056140018
6342719440230
9194384667727
158834950511
13189907695021
16068286986201
1...

result:

wrong answer 172nd lines differ - expected: '10496055340050', found: '8486010645522'

Test #6:

score: 0
Wrong Answer
time: 1078ms
memory: 11040kb

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:

14259860173368
10937025712208
29051567603271
30209611509984
30505349835099
39923616958617
30127758747504
30127921179811
30991963401748
53878998194215
12041408831965
60471743300399
14293907983951
19531534965406
50285175941084
30445845474853
81733296094214
87711352700774
33953838340221
72527000511886
...

result:

wrong answer 43rd lines differ - expected: '100224089792595', found: '99708693717075'

Test #7:

score: 0
Wrong Answer
time: 1777ms
memory: 13196kb

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:

18002902424490
23075462015094
27687561247422
34716605007605
4823257211231
33972194685019
5840674685283
39382189223625
8301227608164
36988995141315
51136592348003
77897512742212
74506491529152
35410072060823
36232809472572
18567561848873
75643345509126
70792388572532
110401829931259
115915157223096
1...

result:

wrong answer 53rd lines differ - expected: '147212921985657', found: '145340316244601'

Test #8:

score: 0
Wrong Answer
time: 2588ms
memory: 15312kb

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
29084657808792
19418073253970
28107337559772
38083878612927
29713402329877
2982175194643
41264971057338
43003569342314
33991492534506
29878529633183
6229195331065
37217752688362
12931980544538
40322468152085
36785511544277
26226261643742
36240726183876
25942496224941
48286296656855
347...

result:

wrong answer 93rd lines differ - expected: '307468825204268', found: '307361451021868'

Test #9:

score: 5
Accepted
time: 481ms
memory: 10436kb

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: 1252ms
memory: 14352kb

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: 1062ms
memory: 11632kb

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 5732nd lines differ - expected: '30315154412158', found: '30310859444862'

Test #12:

score: 5
Accepted
time: 1886ms
memory: 13996kb

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:

ok 66856 lines

Test #13:

score: 0
Wrong Answer
time: 3051ms
memory: 16440kb

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
10256445536363
7713521925846
9888064895489
6256038292188
11730686228782
11039452845716
10094055410970
7576105867469
8385715199583
3244000097042
5648175457135
7...

result:

wrong answer 21216th lines differ - expected: '20145046089644', found: '20140751122348'

Test #14:

score: 5
Accepted
time: 1208ms
memory: 11676kb

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:

ok 75127 lines

Test #15:

score: 5
Accepted
time: 2997ms
memory: 16256kb

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:

ok 126661 lines

Test #16:

score: 0
Wrong Answer
time: 583ms
memory: 9328kb

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
2440353606546
3338526373324
3526540782281
3964210868728
4683453911997
4533231495859
1183818176487
4463903821498
1882352020051
1493031420039
1917691659647
498508969428
4349491092061
4264672051414
2747212074041
3852098941665
4301184848617
4799344784865
2293718458407
4017295011137
1205784...

result:

wrong answer 7850th lines differ - expected: '9779514910093', found: '9770924975501'

Test #17:

score: 0
Wrong Answer
time: 1162ms
memory: 11624kb

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
5578258553292
3146486760439
5780843142249
4830807962015
3392701798953
5047584867818
7223581394262
4928681712837
6452086290943
3467702557813
6079991751019
4223000479199
4385534188535
3986806035303
4702058002154
4274572190362
6539586350661
644997870022
5489357464020
4468270...

result:

wrong answer 4322nd lines differ - expected: '8440731070522', found: '8436436103226'

Test #18:

score: 5
Accepted
time: 2002ms
memory: 13936kb

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
9031859191992
5295432363385
635257284428
2918513105215
3901045794704
4870860169454
2404035076199
2429599868780
553026648922
8327057187216
1015835280888
76763791...

result:

ok 66504 lines

Test #19:

score: 0
Wrong Answer
time: 3132ms
memory: 16436kb

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 38020th lines differ - expected: '20606882837511', found: '20602587870215'

Test #20:

score: 0
Wrong Answer
time: 3137ms
memory: 16316kb

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 19106th lines differ - expected: '3314576118120', found: '3310281150824'