QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#219731#2015. 函数调用ushg8877#100 ✓98ms16880kbC++141.3kb2023-10-19 17:46:492024-07-04 02:20:37

Judging History

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

  • [2024-07-04 02:20:37]
  • 评测
  • 测评结果:100
  • 用时:98ms
  • 内存:16880kb
  • [2023-10-19 17:46:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=1e5+5;
const int MOD=998244353;
vector<int> edg[MAXN];
int n,m;
ll cnt[MAXN],prod[MAXN],in[MAXN],a[MAXN];
ll op[MAXN],p[MAXN],v[MAXN];
void dfs(int u){
	if(prod[u]!=-1) return;
	if(op[u]==1) prod[u]=1;
	else if(op[u]==2) prod[u]=v[u];
	else{
		prod[u]=1;
		for(int i:edg[u]){
			dfs(i);
			prod[u]=prod[u]*prod[i]%MOD;
		}
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	for(int i=0;i<MAXN;i++) prod[i]=-1;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	cin>>m;m++;
	for(int i=1;i<=m;i++){
		if(i<m) cin>>op[i];
		else op[i]=3;
		if(op[i]==1) cin>>p[i]>>v[i];
		else if(op[i]==2) cin>>v[i];
		else{
			int k;cin>>k;edg[i].resize(k);
			for(int &j:edg[i]) cin>>j,in[j]++;
			reverse(edg[i].begin(),edg[i].end());
		}
	}
	for(int i=1;i<=m;i++) if(prod[i]==-1) dfs(i);
	for(int i=1;i<=n;i++) a[i]=a[i]*prod[m]%MOD;
	queue<int> q;cnt[m]=1;
	for(int i=1;i<=m;i++) if(in[i]==0) q.push(i);
	while(!q.empty()){
		int u=q.front();q.pop();
		ll k=cnt[u];
		for(int v:edg[u]){
			cnt[v]=(cnt[v]+k)%MOD;
			if((--in[v])==0) q.push(v);
			k=k*prod[v]%MOD;
		} 
	}
	for(int i=1;i<=m;i++)
		if(op[i]==1) a[p[i]]+=v[i]*cnt[i]%MOD;
	for(int i=1;i<=n;i++) cout<<a[i]%MOD<<' ';cout<<endl;
}

详细

Test #1:

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

input:

900
4348 5020 5146 3902 7591 8327 5240 3157 9415 8168 3232 9418 4796 6325 4174 9395 1105 1465 5685 92 4703 1698 6212 4085 9266 3231 3107 8239 1221 5054 8804 758 4686 7016 2587 8745 3026 6059 4325 4850 836 9830 9870 9251 1892 7458 5567 5680 246 5933 3162 584 415 5752 8968 9576 1776 9873 6528 2617 473...

output:

0 0 0 0 0 0 0 0 0 0 133132283 0 0 0 445991964 332993406 0 0 0 0 0 339750078 0 0 0 486173172 0 929749915 0 0 0 787638328 0 0 386799435 0 580569329 0 0 509984031 0 0 388455096 0 0 0 838251300 0 0 0 507240085 0 0 0 0 675729075 0 0 0 0 739552178 0 972492974 0 0 0 805470429 0 0 0 0 0 0 0 0 936884261 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 133132283 ... 0 0 0 0 0 0 0 383687689 0 0 0 '

Test #2:

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

input:

1000
7045 8767 7117 3139 5305 2401 4056 5312 5901 8564 544 8195 9929 527 125 1191 6291 4339 6143 6741 4959 5691 9433 8954 5657 4920 99 9019 864 5919 8120 5364 109 8957 4892 4265 663 4468 1125 8029 8798 3154 2371 9451 561 1866 3800 85 8461 1839 334 7753 8477 9272 6437 9028 1163 5380 7909 7223 1382 53...

output:

917114098 139212950 11559581 879912260 673598434 481748838 230305663 516235887 391958490 709749401 34826970 733836168 969627679 411001408 327293913 35877841 611941773 428254154 88664548 193008895 893668513 571534048 996593933 213574993 461252508 344339342 626570701 463627376 114033679 133044287 1381...

result:

ok single line: '917114098 139212950 11559581 8... 150321209 898008560 617249492 '

Test #3:

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

input:

894
5107 6849 4826 7754 7129 1396 3030 2575 9724 6881 2104 9415 5660 4133 7672 9151 1387 368 3078 8036 1283 3455 5070 3071 4799 5026 3596 5052 4255 874 7218 2600 1642 2561 1593 3947 3502 6122 5249 16 7100 6202 1933 8370 6312 3436 7981 2892 2144 5131 1070 4131 9 6108 1793 5423 8528 6380 767 1303 6725...

output:

0 0 0 0 0 0 0 0 973891897 0 0 0 0 0 0 0 0 0 0 0 453600474 0 0 677771179 0 0 0 0 0 275489439 0 0 0 589610081 655746487 939044398 0 0 0 0 0 0 0 0 0 0 130583803 0 967357493 0 0 0 0 508569961 0 0 559205149 0 707042370 650692042 248118598 0 0 365375168 19756030 680559189 0 0 0 0 0 0 0 0 46445965 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 973891897 0 0 ...06817 0 0 0 944907591 16708197 '

Test #4:

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

input:

1000
9834 8387 5487 582 5448 8934 4866 8223 1094 2330 2202 4956 5162 6783 7403 9079 3301 5336 7721 849 7802 3553 7118 5456 9809 8791 6944 1691 2954 1668 9135 1208 7068 4486 5348 5845 5307 4941 181 6864 9178 4869 3311 9670 5570 5660 9471 1417 7984 6906 9279 9559 6455 8419 2761 4787 2429 7721 3683 123...

output:

365901606 619635668 87829376 151263461 613002787 200858274 333317444 829139750 893726443 626927719 84367826 948768389 28230395 964368160 878415807 221310133 445623169 419070283 58276087 315409973 113059761 172397109 426854344 42214776 361317069 54845400 235226870 749325598 563038270 553167245 779988...

result:

ok single line: '365901606 619635668 87829376 1... 794078844 944077664 673957802 '

Test #5:

score: 5
Accepted
time: 11ms
memory: 10880kb

input:

19634
4059 5811 7125 9599 9851 7791 8058 825 9905 9445 618 7764 2719 1965 8519 1027 4183 4387 8822 821 538 8625 9231 4586 9907 8682 5976 3694 9107 4937 8430 6189 9819 4029 2522 5704 4563 9907 8103 7891 7896 9952 7599 9860 9465 3625 9811 8840 9112 2024 6530 5217 4246 9199 9662 6855 9378 3062 905 8804...

output:

4059 5811 121809 9599 9851 7791 39898 825 9905 9445 618 7764 2719 1965 8519 1027 4183 4387 317128 821 538 8625 9231 4586 9907 8682 5976 3694 9107 4937 8430 132363 9819 199845 2522 5704 61711 9907 8103 75261 7896 9952 7599 9860 9465 3625 168655 8840 9112 2024 6530 5217 123399 9199 9662 50097 9378 306...

result:

ok single line: '4059 5811 121809 9599 9851 779...5 32796 573 3021 802 8221 4421 '

Test #6:

score: 5
Accepted
time: 10ms
memory: 11404kb

input:

20000
6896 5397 9361 7131 1237 7416 1009 5380 8265 9284 4995 4169 3459 2057 3288 1229 6520 5974 6052 2430 2180 489 2586 7876 5049 1432 1054 140 3463 5726 2705 1709 6688 2528 5823 7282 6869 8013 8953 4366 5371 2338 4323 8910 9564 2510 1310 7045 3176 3616 8795 4797 8256 8384 1001 1731 3985 4226 4199 6...

output:

170391278 100058806 254748889 751462190 391009636 882705689 685312578 113245917 811328412 608080025 881657244 406710831 605145107 400848275 326750137 103614055 638219913 239675305 296610249 698710106 951358465 971242520 812579994 936919772 76405445 533346996 180643471 537323079 249720721 314611471 7...

result:

ok single line: '170391278 100058806 254748889 ...8 689292301 816138883 39564973 '

Test #7:

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

input:

19122
5492 6379 7545 7699 4883 8402 9962 7733 3739 8132 1704 5719 7603 544 3525 9957 5150 140 6757 9886 7584 8895 2471 5860 3837 7265 5353 1175 9001 9618 6453 577 1717 4673 7526 4772 7728 3926 2256 1729 6227 8948 1309 2684 2502 1506 6839 1399 5308 1284 384 6144 7010 980 6205 5884 5657 2709 3014 3541...

output:

69759546 182450199 157272827 700156688 327762037 444538841 610411657 379230943 145281574 227282925 574239217 422719131 608055615 854654198 168737263 811171476 303161922 817230205 607488446 521089327 288274296 391809541 75384846 589187718 787131124 315007413 882657327 388993872 322961938 56006258 482...

result:

ok single line: '69759546 182450199 157272827 7... 712765550 107535692 893554594 '

Test #8:

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

input:

20000
8290 5590 7 7401 4037 5074 3441 4798 4481 188 5919 3173 373 2213 8471 8189 867 3755 2908 4718 4175 1456 4926 6623 2192 469 1936 653 2170 4671 3511 8868 2919 3114 1588 9247 1415 4903 1829 8978 1558 5672 8195 363 2018 9213 8913 1648 9772 8404 4474 1958 2522 1355 1561 7612 3816 4754 588 2768 1070...

output:

0 0 0 0 0 0 0 0 949491183 0 0 0 0 0 0 0 274815705 0 0 0 0 0 0 0 0 0 0 0 0 0 750289225 0 0 0 0 0 0 192596322 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 988504277 0 0 688698007 875604829 423856680 0 330586111 0 0 0 0 0 0 603524174 0 374998013 0 0 0 0 0 0 0 0 0 0 0 436281999 ...

result:

ok single line: '0 0 0 0 0 0 0 0 949491183 0 0 ... 0 0 747276127 0 806193951 0 0 '

Test #9:

score: 5
Accepted
time: 9ms
memory: 10600kb

input:

17482
2569 2644 5807 9275 965 2422 339 9256 9038 7111 4396 6581 3274 272 2443 7428 6180 826 4400 281 2121 3456 7341 1602 7316 2647 2517 5688 4389 6384 8864 3780 2223 8481 6306 8344 1539 4911 3527 6647 1755 1590 3499 2665 4983 7983 5934 3807 8770 2305 5201 2361 8507 1663 1284 9667 8465 4375 7711 39 6...

output:

152448895 736650624 963982963 705435188 241577839 285166278 566484810 450958019 392240520 513293700 927269135 244812980 487839171 175455930 408812988 240675185 22844655 870459848 665608217 85841041 509385474 526434979 441456210 20459406 579470418 41282759 559307770 201380898 886053565 653558779 1393...

result:

ok single line: '152448895 736650624 963982963 ...9 651604666 30392351 621892696 '

Test #10:

score: 5
Accepted
time: 14ms
memory: 11532kb

input:

20000
1003 5789 2599 8143 5827 1042 153 3993 5976 3355 5481 7461 9736 2892 5761 6464 8560 2860 1192 3197 4652 6063 7076 1066 5930 9344 239 6480 8234 2321 5596 3469 197 5843 8142 9931 1541 2829 7327 5242 4516 1074 8183 5480 7064 753 8132 5760 3904 2891 8177 6495 2372 4954 7092 3315 7235 7010 6414 893...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 565747312 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 903639406 0 0 0 0 782715622 0 0 0 0 0 704988721 0 0 0 0 0 0 612904571 0 0 0 0 0 0 0 0 0 622020347 0 0 0 0 0 0 0 430476773 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 153420731 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 22130227...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 600186976 0 0 3421136 0 0 0 0 '

Test #11:

score: 5
Accepted
time: 21ms
memory: 11476kb

input:

19502
2827 6571 5170 4828 3116 5757 253 8321 1074 2836 7166 1665 8 3346 4100 7347 296 9396 6320 6589 7443 4588 8318 9345 8467 2417 2955 6439 6058 4005 1787 5824 2384 3250 8775 2718 9344 6201 2059 3707 948 3057 2283 3286 8403 5926 9923 5728 9628 5246 3017 8267 7994 4861 4428 7599 271 3378 1868 7228 6...

output:

281269410 29827917 572647035 600414500 190671698 364451300 17403532 880149602 105444064 254269099 19463984 994408583 197831802 387992064 566118872 252870004 332066203 760761553 486402847 974071648 630362922 654926558 556401588 248267080 996724753 623955264 451845183 758580596 570601291 962038194 517...

result:

ok single line: '281269410 29827917 572647035 6...5 77932317 544879570 121072278 '

Test #12:

score: 5
Accepted
time: 49ms
memory: 14280kb

input:

99949
7992 2982 1065 761 9828 968 3944 10000 3744 7140 1818 3377 7117 4694 6038 6092 5093 4575 1044 609 8809 3538 6420 3210 6389 5973 4401 8749 3102 949 3532 7886 4414 1544 761 9602 4846 2729 7868 3343 2459 8169 6363 5382 9302 7872 2060 9620 9110 6366 745 3240 1432 3944 7691 494 5368 9921 5292 5256 ...

output:

7992 2982 1065 761 9828 968 3944 10000 3744 7140 1818 3377 7117 4694 6038 6092 5093 78719 1044 609 8809 3538 6420 3210 6389 28589 130031 8749 3102 949 3532 26373 4414 1544 761 9602 41611 2729 7868 3343 2459 8169 6363 5382 9302 13006 2060 9620 9110 6366 117771 3240 1432 3944 33411 496861 5368 9921 52...

result:

ok single line: '7992 2982 1065 761 9828 968 39...913 9453 2872 142624 4378 5325 '

Test #13:

score: 5
Accepted
time: 50ms
memory: 13852kb

input:

100000
3965 6421 269 1932 3129 2275 6289 581 7242 9622 5018 5606 8265 3610 2115 3038 6565 8398 1979 3391 7602 5234 6337 8035 4968 3548 3090 6228 3311 1065 3360 4454 9417 1186 1618 644 5824 8035 8913 2486 1094 5964 7171 9879 8790 7873 4208 6207 34 4050 375 8166 9238 5636 605 4290 9892 9413 6921 7416 ...

output:

760886980 410185999 576549325 73670948 683539974 289292543 82738255 80023907 722571494 364838967 832041312 203433979 265558451 333998435 799881053 911546917 948900693 776985833 734759110 970476186 72869523 641869000 927806055 874748890 617258589 906193115 496044563 838912573 227526088 282421282 2583...

result:

ok single line: '760886980 410185999 576549325 ... 549299460 273749439 342349708 '

Test #14:

score: 5
Accepted
time: 30ms
memory: 12052kb

input:

100000
2248 1748 3904 16 9497 5833 9323 6431 1629 5165 5978 5354 2983 6886 1557 8840 4636 3486 2971 140 692 8653 2116 3409 3944 2876 108 3812 605 3896 494 4826 6277 3441 2144 546 3569 8942 1004 761 1551 674 785 5170 3977 6777 2278 1051 8907 6476 5269 4508 9591 7797 1482 1583 7365 2915 3970 5495 4336...

output:

858280011 516029985 480918594 271987893 911643722 517566111 324605724 825450626 676779553 305469554 600898794 48932028 417268905 386980693 950200564 182669004 196749198 505008595 155802327 632966446 361183323 290142220 782285406 738540971 661766150 53715311 88990660 663915827 239708402 844046824 373...

result:

ok single line: '858280011 516029985 480918594 ... 571411044 532000299 526096147 '

Test #15:

score: 5
Accepted
time: 36ms
memory: 13400kb

input:

100000
7815 2040 9527 3033 447 4734 4056 5019 5883 2162 1089 7338 7744 1823 4277 1321 6627 1624 7043 1505 3326 1821 278 5777 3378 9086 1839 3248 7698 5005 812 3807 6636 8030 7829 7880 8701 2021 4766 1716 1171 989 9462 2239 3568 7854 8391 1435 4531 4854 7328 1 5004 4692 8048 221 4241 6893 9301 7038 3...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 992274769 0 701048163 0 0 0 0 0 0 0 0 0 0 0 745671549 0 0 884406564 0 0 0 0 0 520188648 0 0 811952256 0 0 0 0 0 0 0 0 0 0 0 0 71907554 0 0 0 237081850 0 0 0 0 0 0 0 0 996742962 0 0 0 405298837 0 0 0 0 0 0 0 0 0 958783345 142524934 0 953759073 0 0 0 0 0 0 0 0 0 0 713594924...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 99...59 0 278606429 0 0 0 0 0 0 0 0 '

Test #16:

score: 5
Accepted
time: 39ms
memory: 13368kb

input:

99977
1189 9781 8144 9695 8440 9569 8152 4451 7511 7373 9734 3293 3944 2293 213 6968 6404 2817 240 8802 6411 6748 3886 2707 6561 2206 4043 240 4584 5081 2422 3717 4647 5321 6901 2354 5177 9251 158 9 5796 663 6896 2783 6036 5630 654 3187 9303 8521 332 6791 2792 7343 6559 9131 6588 9412 5204 4047 8685...

output:

768355673 200946163 222937197 290522620 936086869 607482425 377109398 729389299 127774573 712598253 168648291 946079630 140324265 271709684 696285378 205549561 131669305 562443731 289785918 675107405 391350525 771607830 270381249 883214878 536907323 238630327 675619267 862180222 495168109 964136375 ...

result:

ok single line: '768355673 200946163 222937197 ... 270381249 407944357 837876636 '

Test #17:

score: 5
Accepted
time: 59ms
memory: 14444kb

input:

99948
9368 4701 6614 7377 6883 2277 4445 6534 3188 8555 5080 1156 6828 3547 2476 4221 4180 2609 853 1504 9820 1804 7029 1340 7676 3026 4158 4124 7325 5798 5344 5962 8338 7796 9387 3458 7878 116 1861 609 311 854 2769 8729 1489 6321 1604 5335 3524 2455 6378 6025 368 1710 6651 8038 3756 1983 941 1923 3...

output:

0 0 0 0 0 0 0 0 45323738 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 803782155 0 0 0 0 0 0 0 0 937913473 0 172774616 0 56556863 0 0 0 0 635683460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 837585858 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 45323738 0 0 0... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '

Test #18:

score: 5
Accepted
time: 66ms
memory: 15176kb

input:

99923
1195 2554 3320 2520 275 5164 6984 4917 8710 1204 8722 419 2350 9923 2761 3301 6832 2623 4809 5455 7818 3418 3857 931 7695 2009 6847 2303 2873 2031 6072 4972 6741 3130 4675 538 9158 3826 364 3301 4656 706 7067 7172 8626 2524 3600 1342 3976 4396 5292 8276 3354 7544 6164 2725 102 8726 5818 7954 3...

output:

784634385 256854242 822459485 455897911 63615269 479473133 864190755 897862365 272478922 761306483 906871288 688613190 452871903 12213150 718556849 317127082 189162788 410755111 179552836 151168449 33464307 13864356 761553803 803423275 19530850 893076033 110132871 463779352 650086147 59639998 566099...

result:

ok single line: '784634385 256854242 822459485 ... 713315894 173184399 421029718 '

Test #19:

score: 5
Accepted
time: 86ms
memory: 16728kb

input:

100000
1107 7500 555 8157 2537 8934 5572 4420 1534 8876 724 1965 3243 869 2671 6570 8493 6491 6276 941 4772 6520 2942 4339 1196 1297 9838 9189 4939 3004 8546 1951 3636 9159 2888 5970 4170 4615 5216 6561 8097 9006 9340 6771 487 4609 81 8044 3426 8836 1466 2134 249 2924 7666 5259 3718 1095 1166 9077 8...

output:

87645022 831864656 812237738 989387121 798696068 728977860 425824669 245342956 214333001 964253006 539761269 393639546 235117382 949817757 696617268 576980297 418124900 36885795 702493108 898707592 882799352 917492575 767669879 677183524 759285939 590538201 596855005 589556207 681957139 585013299 61...

result:

ok single line: '87645022 831864656 812237738 9... 831864656 771704085 448117451 '

Test #20:

score: 5
Accepted
time: 98ms
memory: 16880kb

input:

99974
2890 6844 4555 596 8778 6586 785 9728 7606 3029 3794 7041 8620 8312 895 3629 3095 7139 7965 9293 9621 653 7027 6993 7613 4082 1516 5707 1545 7356 8129 5062 822 6513 6923 6179 95 9983 2092 4743 5316 3815 7169 4569 880 9186 6398 7353 5231 6469 8584 3582 7080 9121 5192 7641 9910 54 9969 8043 1695...

output:

394638844 156699642 138421398 658916716 271575062 561525415 559685673 491108084 818250225 126235902 817901686 803272037 16500280 252154154 332917239 159809984 788770324 456042799 96310415 117381351 747991719 232861182 995482550 321428821 223022792 714227923 577297728 721970699 535663220 196162406 41...

result:

ok single line: '394638844 156699642 138421398 ...8 964859985 58611263 685762750 '

Extra Test:

score: 0
Extra Test Passed