CT52989

Ulric's Wistful Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Ulric found an old ledger of registers in the workshop attic at the shale slopes of Greystone. The margin notes pose a precise question. Task: Answer q queries 'l r' giving the XOR of a[l..r] (1-based, inclusive). Input format: First line: n and q. Second line: n integers. Next q lines: l r. Output format: Print one XOR per query. Constraints: 1 <= n,q <= 4000; 0 <= a[i] < 2^31; 1 <= l <= r <= n.

Example 1:

Input: 3639 1657 551149821 1737324107 330175651 1362265719 1916508652 952440490 256880839 2141400159 1112882567 1760568436 1632980799 1682315767 1312445466 734683511 1956881971 549253768 110868498 514499122 104758363 2018229597 505016990 1111490140 1655220515 803077386 360204275 1703092725 1739641181 594924571 1443830195 1099259054 847125209 152486505 1534540185 1603916617 766948047 1625566074 1941366451 983116239 1516027828 127423220 819918611 591685858 1660823279 127110406 1579639649 593139144 306484865 445911769 681302990 519918887 2032654204 1045059068 200054084 302619035 1090339099 1245708572 563997278 1054961165 831124870 31740372 1277589236 1989657231 200578285 1537325420 58407537 1004506544 1896965393 1505594775 1706083668 1733004855 64864793 345694210 1919127872 1882089261 1593708974 183…
Output: 1043024196 93250119 174458954 341029260 322776738 482565574 1004495873 564884778 1484125303 1946866515 63209458 179393657 850853320 988821245 1589570099 1749395168 1732901939 1885034364 1716031211 1218326281 724232585 519931253 1286773162 1504447796 1156041753 1327658299 167915831 1295388241 1257352411 289085021 849147081 612025134 972682792 64461569 159453058 132909994 2046693569 1682983335 14931823 1049954929 109979873 323577603 1952247997 1233745809 339581243 1032487327 1007294200 1965984906 859744378 671863528 413160109 1016355948 739301693 912772497 395063627 2144157549 754054459 1405995020 1766588833 131463103 594615309 2121498174 735290259 1974080826 1899505467 1479924808 1981673256 1019421874 1175764747 1316194840 1603678288 810321701 936147232 794375710 252783606 1274333554 137652…

Example 2:

Input: 1277 2206 1789738241 764130501 215632025 902173941 325686042 646144198 1710996809 709704920 1590256463 695672789 261444721 1944815516 717809988 2089051920 1636309793 1218031385 1241157967 1482993771 1044428008 76153849 35684251 2134364476 1761218490 327675674 865334702 855231491 1056320450 461657089 774409180 158007318 1382484064 1213485762 1803527259 300886697 1475835066 1670693203 1055822290 1721757096 837808619 1927164444 1133202500 1679520323 58894682 1162259914 1534800726 1279246720 2031402302 1103627457 1290201511 113699986 997510397 631262199 1667905938 2094459662 480797646 1782355568 603806060 1504745630 1212868847 1981382252 2143327745 597092816 367121956 2120387240 1079627984 738479338 1894404699 34267573 343613282 438142835 1240887978 1280215130 885929276 721810099 2132094913 16…
Output: 1575115696 1633391153 1259749467 1341182231 1778060418 565152079 2040976683 232255215 67640128 329876830 674252227 2029813570 1358399238 1168925473 1105594102 472750256 1534730529 657254067 1880482828 1984203518 1894616907 1415646948 189703323 1048352844 1924171969 1989119011 1758429340 700169677 1147258392 1926201686 1365681249 1148586279 166222798 1531781531 1589592958 886983525 2044992353 928194001 1152080469 1120346835 1361436971 65827566 2050900659 862739535 91525812 980541056 173144851 1865681468 569002768 1006348882 389114009 2049715137 1568672131 827443063 1441952818 650059331 2131587779 137235517 625739401 1635086387 1066180997 1713888695 1212539880 2052924984 152513529 1787664394 1053102252 681560377 1817848072 726871987 109700909 533517397 1731230343 593812412 1048693550 1688725…

Example 3:

Input: 1959 2439 1169108693 941664699 1203790120 1297185249 943754210 317517218 1381725991 1957512512 1480260704 648432894 1147060930 1038790798 879452915 410340061 769861210 573643689 1553100125 660191238 1649055248 1033761257 389745585 411238361 297895512 376089626 1162223706 1643499015 1538238339 1051089789 1938283996 1232887067 2080409083 349748873 1739016689 551479369 24824623 1305883680 147725956 643987096 1363584194 355935049 482322037 1317854390 2050789119 550238230 1905033586 676416983 1095117422 1452689264 1719743206 1580836556 735049450 1138033752 62386187 207221495 1686547533 830509277 643823620 542958566 405678228 1498683971 385517304 1729500051 1367525462 797529718 430189612 1702295110 2093133885 407348870 1820051822 1621547037 999949102 2075869457 1312275295 1546303789 1058018655 1…
Output: 1665265861 1623290774 1833469298 2073035854 2057322052 84952221 1480960986 338641266 1289620067 1493127563 182439896 1106160615 55746875 1913310834 1768835928 142814290 1549962206 246324150 457398782 853122847 673698397 649371454 1964964438 1225449162 1374037508 2094862082 136229017 574441256 1129759834 249822285 1563091065 1817098775 1045405658 1755266327 437252199 16634418 374937414 1512170175 1931486442 2129135549 2080087389 1061310685 1377502581 212609798 1138045296 94012021 345584080 434104837 1686871915 360137338 1725090121 2121161638 1335679035 1751042328 1988898440 1773339816 1926769768 943270181 453585206 200359992 1614012026 682885559 625151433 18257257 788091820 2119814654 1197419864 1375618951 209223369 582313545 156361270 1898057287 1753506556 33944190 68052412 1351347690 2134…

Constraints:

1 <= n,q <= 4000; 0 <= a[i] < 2^31; 1 <= l <= r <= n.

Loading...
Test Cases:No test cases
No test cases available.
Ulric's Wistful Ledger - MEDIUM Coding Problem | CodeTikki