QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89103 | #4062. 军队 | james1BadCreeper | 15 | 3129ms | 16432kb | C++14 | 2.6kb | 2023-03-19 00:49:28 | 2023-03-19 00:49:32 |
Judging History
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, 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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 4572kb
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: 0ms
memory: 4548kb
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: 4588kb
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: 4812kb
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 168696872082 195661348797 5864568809 198753194838 115698223343 242832653141 116590217065 135227354893 236344435118 1425793...
result:
wrong answer 15th lines differ - expected: '168904035170', found: '168696872082'
Test #5:
score: 0
Wrong Answer
time: 522ms
memory: 8876kb
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 3894996224288 288865749911 4131683517578 8589714311865 8360296283837 6941829283179 1088002407774 11156868266329 12989447539438 2509229221904 11577963604684 11480359874198 11360153338516 6340359686113 9180596603580 116724428323 13193227932181 16071607223361 1...
result:
wrong answer 4th lines differ - expected: '3896813649786', found: '3894996224288'
Test #6:
score: 0
Wrong Answer
time: 1090ms
memory: 11164kb
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 30992450638198 53878998194215 11957984105206 60471743300399 14289298217692 19531534965406 50255736984172 30445845474853 81719780001780 87711744527610 33889348717486 72527000511886 ...
result:
wrong answer 9th lines differ - expected: '30991963401748', found: '30992450638198'
Test #7:
score: 0
Wrong Answer
time: 1837ms
memory: 13208kb
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 33947500695268 5840674685283 39382189223625 8301227608164 36988995141315 51134577441153 77895497835362 74504476622302 35408057153973 36232809472572 18567561848873 75643345509126 70792388572532 110298065077270 115913142316246 1...
result:
wrong answer 6th lines differ - expected: '33972194685019', found: '33947500695268'
Test #8:
score: 0
Wrong Answer
time: 2779ms
memory: 15304kb
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 36783734865357 26226261643742 36240726183876 25942496224941 48286296656855 347...
result:
wrong answer 16th lines differ - expected: '36785511544277', found: '36783734865357'
Test #9:
score: 5
Accepted
time: 539ms
memory: 10392kb
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: 1400ms
memory: 14312kb
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: 1099ms
memory: 11708kb
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: 1949ms
memory: 13944kb
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: 3065ms
memory: 16432kb
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: 1050ms
memory: 11624kb
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 39th lines differ - expected: '4442755853222', found: '4442685297930'
Test #15:
score: 0
Wrong Answer
time: 2976ms
memory: 16324kb
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: 567ms
memory: 9252kb
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 23rd lines differ - expected: '4420998524920', found: '4420990917069'
Test #17:
score: 0
Wrong Answer
time: 1164ms
memory: 11652kb
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 33rd lines differ - expected: '4361145739481', found: '4361024001345'
Test #18:
score: 0
Wrong Answer
time: 1941ms
memory: 13968kb
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: 3072ms
memory: 16404kb
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: 3129ms
memory: 16320kb
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'