版本比较
膜拜CSP英语课代表
正文
增加 125 行删除 125 行
5 行未改动6789101011121314131415161718192021181920212223242425262726272829303031323334353334353637383839404041424344454546474847484950515051525354555657585953545556575859606162636465666767686969707172737374757576777879808182828384858616 行未改动1031041051061071071081091101112 行未改动1141151161171181181191201211221231241251261261271281291301311321331341341351361371383 行未改动1421431441451461461471481491507 行未改动1581591601611621621631641651665 行未改动1721731741751761761771781791801811811821831841841851861871881891901911911921931941951961971981991992002012022032042052052062072082092102112122132142152162142152162172182192202212212222232242242252262272282 行未改动2312322332342352352362372372382392392402412422422432442452452462472482492492502512512522532542552562572582582592602602612622632642642652662672682692702712712722732742752762772772782792802792802812822832842852862872872882892892902912912922932942952952962972982992993003013023033043043053063073083093103113123123133143153163173183193193203213223233233243253263263273283293303313323323333343353363373383393403413413423433443453463473483493483493503513523534 行未改动3583593603613623623633643653663673683693703713723723733743743753763763773783793803813823833843843853863863873883893893903913913923933943953963973973983994004014024034044054054064074084094104114124134144134144154164174184184194204214204214224234244244254264274284284294304314324334344354354364374384394404414404414424434444454464474484494504504514524534544554564564574584594604604614624634644654664664674684694704714714724734744744754764774784794804804814824824834844844854864874874884894904914924934944954964974974984995005019 行未改动5115125135145155155165175175185195205205215225235235245255265275285295305315325335335345355365375375385395405415425425435445455465475485495495505515525515525535545555545555565575575585595605605615625635645655665665675685685695705715723 行未改动5 行未改动#include<fstream>#include<iostream>std::ifstream fin ("polygon.in" );std::ofstream fout("polygon.out");long long M = 998244353; long long M = 998244353;long long p(int n) { if (n == 0) return 1LL; if (n % 2 == 1) return 2LL * p(n-1) % M; return 1LL * p(n/2) * p(n/2) % M; if (n % 2 == 1) return 2LL * p(n-1) % M; return 1LL * p(n/2) * p(n/2) % M;}
int n;int a[5002]; long long knap[5002]; int count[5002]; int summing[5002]; int a[5002];long long knap[5002];int count[5002];int summing[5002];
int main () { fin >> n; fin >> n; for (int i = 0; i < n; i++) { fin >> a[i]; count[a[i]]++; fin >> a[i]; count[a[i]]++; } // build knapsack knap[0] = 1; knap[0] = 1; for (int i = 0; i < n; i++) { for (int s = 5000 - a[i]; s >= 0; s--) { int odex = s + a[i]; knap[odex] += knap[s]; knap[odex] %= M; int odex = s + a[i]; knap[odex] += knap[s]; knap[odex] %= M; } }
// for (int i = 0; i <= 5000; i++) {// std::cout << i << ' ' << knap[i] << '\n'; // std::cout << i << ' ' << knap[i] << '\n';// }
// build interval sum for (int i = 5000; i >= 0; i--) { summing[i] = summing[i+1] + count[i]; summing[i] = summing[i+1] + count[i]; } long long ans = p(n);
long long ans = p(n); for (int i = 1; i <= 5000; i++) { ans -= (knap[i] - count[i]) * summing[i]; ans %= M; ans -= (knap[i] - count[i]) * summing[i]; ans %= M; } ans -= n*(n-1)/2; ans -= n; ans -= 1; ans %= M; ans += M; ans %= M; fout << ans; ans -= n*(n-1)/2; ans -= n; ans -= 1; ans %= M; ans += M; ans %= M; fout << ans;}
/**
you might notice that, for once, there arecomments! hooray! that's because this shitis hard. is hard.
well, not like that hard, but yah. well, not like that hard, but yah.
first i had no good ideas so looked atdata range, found a=1 case to be easilybashable (quickpow 2^n for all cases, bashable (quickpow 2^n for all cases,subtract degenerates which are n*(n-1)/2for two, n for one, and 1 for none). for two, n for one, and 1 for none).
then i also bashed the n<=20 case, sinceit was fine as well. i didnt do a particularlyelegant solution - nor do i believe one exists- but its basically bit for 0 to 2^n, checkover bits for >=3 sides, sum>2*max. nothingcrazy. crazy.
(this is when i find out i have 2+ hours left)
then i started thinking. data range being16 行未改动do oi comp that seriously anyways. so besideit i wrote "2.5x10^7 doable?" because imfucking stupid as shit and thought knapsackwas like fucking O(n). its not, you fuckingretard, its fucking O(n^2) retard, its fucking O(n^2)
well, O(mn), but its the same thing here
i wrote "complementary counting", which2 行未改动that was pretty badly tle)
i wrote 350-360 since that was how much i wasexpecting to get by brute force. now its beenbumped to 400. bumped to 400.
then i thought about how i could consider"violators", essentially the max elementin a non-polygonal non-degenerate. so likein 1 1 2 5, the violator would be 5. and thiswas nice because you can't have >1 violators,which meant i just had to solve for eachviolator. violator.
so then i wrote "PROPER INVALIDS" which isbasically just non-polynomial non-degenerates.
so i then wrote "RATHER THAN case-by-casebasis" which i honestly dont know what ireally really wanted but i guess its part ofmy train of thought. my train of thought.
then i drew a graph like this
| sorry, i have to interrupt myself as an3 行未改动| night-time"), so i thought id plug my| medium.com account which is like probably| NumberBasher or something which has a| fanfiction called "the curious incident| of the **fork** in the night-time" | of the **fork** in the night-time"| (emphasis mine) which is currently in| release so go check it out i guess
i digress; i drew a graph like this7 行未改动xx
which is supposed to be like thecount of all the different a_i's? count of all the different a_i's?although im not sure why i thought thedistribution was like this, probably sincei thought this was the most interesting case.
5 行未改动"calculate: # arrangements which FAIL me"
at this point i returned to the idea ofviolators that i had earlier which was acorrect idea (ill refer to my sol as correct idea (ill refer to my sol as"intended" for sake of ease, even though itmay or may not be intended) so it was intended
for a given violator, the sets that satisfyit must sum to at most it. lemme give a it must sum to at most it. lemme give aconcrete example: if the violator is 5, thenthe sets which constitute this violatorare sets which sum to 5 or less. are sets which sum to 5 or less.
but thats not exactly what i wrote sincei was considering the violators that a setcan constitute. but i guess both are equallyfine and solveable. so for sets which sum to5, they constitute violators of all numbersequal or greater than 5. equal or greater than 5.
finally i reconsider the added constraint thatthe invalids i generate must be what i termproper invalids, so that means that set musthave at least two numbers, which was as simpleas removing the count of numbers which are 5.
so i wrote down the algorithm: start with, so i wrote down the algorithm: start with,again, the quickpow result of 2^n (mod thatthing), then subtract off [the number ofsets which sum to x, minus the number ofnumbers which are x], multiplied by thenumber of numbers of x or higher. and thenfinally subtract off n(n-1)/2 and n and 1. finally subtract off n(n-1)/2 and n and 1.
then i implemented the knapsack, thecounting, the suffix sums
i personally really like how i resolve mods,im pretty sure its established waaaaay beforeme but something strikes me as elegant with
ans %= M; ans += M; ans %= M; ans %= M;ans += M;ans %= M;
(but also this proves my point of c++ beingstupid. i never could understand why modulusand integer division respected sign and notmath. its fucking stupid. fuck you, c++, math. its fucking stupid. fuck you, c++,fuck you)
and so after all that was implemented, and so after all that was implemented,ale li pona (which is toki pona for"all is good". i should plug wasona.comfor being an excellent resource to learntoki pona; im currently contributing chinese2 行未改动or so i thought.
it passed test case 1.
it passed test case 2. it passed test case 2.
it passed test case 3. it passed test case 3.
it failed test case 4. it failed test case 4.
by this point i had a pretty good idea ofwhat went wrong. what went wrong.
you see, c++ is not just fucked becauseof its fucking declaration and initiation, of its fucking declaration and initiation,not just fucked because of its fuckingfucked i/o fuckery, not just fucked becauseof its modulus operator fucking around allover the fucking place, but also fucked over the fucking place, but also fuckedbecause of the fucking integer limitbeing fucking stupid as fucking shit. being fucking stupid as fucking shit.
(i guess this is a good time to say that imnot claiming c++ is actually bad, im justfucking around. there are obviously reasonsfor many of its design choices and i respectthem. well, all of them except the modulusoperator. just why. why. just why.) operator. just why. why. just why.)
so this was an integer overflow issue, so this was an integer overflow issue,and specifically inside of my (then int)knapsack. because holy shit can the numbersget fucking huge. so i just changed it tolong long and i passed test case 4. long long and i passed test case 4.
ni la (and so), ale li pona
if i was fucking stupid, which i fucking wasnt
you see, c++ is not just fucked becauseof its fucking declaration and initiation, of its fucking declaration and initiation,not just fucked because of its fuckingfucked i/o fuckery, not just fucked becauseof its modulus operator fucking around allover the fucking place, not just fuckedbecause of its fucking integer limitbeing fucking stupid as fucking shit, being fucking stupid as fucking shit,but also fucked because of the fuckinglong long limit also being fucking stupid as fucking shit. long long limit also being fucking stupidas fucking shit.
(i dont actually mean any of this lolobviously im the one at fault here)
clearly, 2^5000 is not within long long[citation needed], so i had to mod itbeforehand to not fuck things up. beforehand to not fuck things up.
ni la, ale li pona a. ni la, ale li pona a.
this is a nice problem. a+*. this is a nice problem. a+*.
now, you probably dont know this but itscurrently 11:12 am, which is to say thati still have 48 minutes left. oh well. i still have 48 minutes left. oh well.
i guess there's not much to do except for meto dump my life philosophy on whoever may bereading this. reading this.
and i also thought about coming out asautistic through this piece of writing but iguess its pretty obvious anyways. i do reallylike yapping, huh. like yapping, huh.
uh well if we met in person id ask if you'dlike to receive a toki pona lesson or a briefpiece of writing on tulpamancy. but i reallydont think i know enough about tulpamancy andthere are a lot of excellent resources onlineso really really you should just check themout. out.
and on this topic im suddenly aware of thefact that i may or may not have accidentallycreated a christopher tulpa, or, for thatmatter, if that had now been part of me. suchinteresting questions, however, requirefurther thought before they are conveyed. further thought before they are conveyed.
who knows, you might see them on csp-s. butcsp-s is like hard so i probably won't havethe 30+ mins i require to type it all out. the 30+ mins i require to type it all out.
so i guess that leaves toki pona huh. ok,brace for infodump. brace for infodump.
id also strongly recommend you to fact-checkme especially with places which i haveattached a question mark to since these arethings that im not completely certain aboutfrom memory. from memory.
anyhow, toki pona is a conlang, which meansits a "constructed language" as opposed toa natlang which is a "natural language". itwas created by californian polyglot (whichmeans one who speaks many languages)Sonja Lang (the j is pronounced as in the"y" from "yellow"; its IPA is, &lit (andliterally), /j/). literally), /j/).
some say toki pona was designed to beminimalist. it isnt. maybe it can beconsidered slightly minimalist, but theoriginal design choice was for it to simplifythought because sonja lang was then goingthrough depression, but not in such a way as to render the language minimal. through depression, but not in such away as to render the language minimal.(i know that there have been someattempts to further minimalize toki ponawhich you can read about but i cant fetchfrom memory.)4 行未改动in which case i have just the answer for you.
the short answer is that "toki" meanslanguage and "pona" means good. the longanswer, well you'd have to read on. answer, well you'd have to read on.
before we delve deep into the abyss of vocabin toki pona like
kijetesantakalu (raccoon or squirrel)
, we should start of learning about howsentences work. sentences usually have:
HE EAT APPLE. HE EAT APPLE. ------ ------- --------- subject, verb, object. subject, verb, object.
(you can have sentences without objects, (you can have sentences without objects,but that's usually it. S, V, O.) now toki ponaalso has S-V-O in this order, BUT it hasspecific markers for verb and object. theseare, for the most part, hard requirements fora sentence to be even minimally grammaticallycorrect. these are also necessary to clear upcases of ambiguity, as we'll talk about laterafter we touch on modifiers. after we touch on modifiers.
The specific markers are `li` and `e`. The specific markers are `li` and `e`.
ona li moku e kili. ona li moku e kili. ------ ------- --------- subject, verb, object. subject, verb, object. ( HE EAT APPLE. )
the exception to the requirement is that `li`can be omitted when the subject is just`mi` (me) or `sina` (you), since it is moreconvenient that way. convenient that way.
(you may note that the english sentence as isisn't correct since you'd have to have either"an apple" or "the apple". but toki ponadoesn't have such constructs - or at leastthey are not required. the two here would betranslated as "ona li moku e kili wan" and"ona li moku e kili ni", respectively. "ona li moku e kili ni", respectively.its also probably worthwhile to note that"ona li moku e kili" does not imply that thereare multiple apples, either; that would be"ona li moku e kili mute". its just missingany identifying information about the apples.)
if you've read the above, you can probablymake some educated guesses on what "wan", "ni", and "mute" are: "one", "this/that", make some educated guesses on what "wan","ni", and "mute" are: "one", "this/that",and "many". one thing you may notice is thatthey come AFTER "kili", which is to say thatin toki pona, modifiers come AFTER the thingsthey describe. they describe.
ona li moku e kili suli. he [verb] eat [obj] fruit big. ona li moku e kili suli.he [verb] eat [obj] fruit big.
here, for instance, "suli" (big) modifies"kili" (fruit), so the kili is suli. "kili" (fruit), so the kili is suli.
if we were to want to describe the fruitas, say, suwi (sweet) as well, then we wouldwrite "big sweet fruit" as "kili suwi suli". write "big sweet fruit" as "kili suwi suli".
one issue which may arise is when groupingmodifiers, since modifiers can act on othermodifiers. for instance, consider "the doorof my house". me modifies house, yet my housemodifies door. in such cases, we use "pi" forgrouping. grouping.
lupa pi tomo midoor ( house me
so evaluating would be "tomo mi" = my house, then "lupa pi tomo mi" = my house's door. so evaluating would be "tomo mi" = my house,then "lupa pi tomo mi" = my house's door.
a clearer case for why this matters:
kasi ma miplant land me
"land's plant" would be interpreted as "grass", so "kasi ma mi" would be (kasi ma) mi, mygrass. however, grass. however,
kasi pi ma miplant ( land me
would more likely mean a plant (or any plant)which is on or belongs to my land. which is on or belongs to my land.
now let's talk about prepositions! commonprepositions are "tawa" (move to) and "lon"(at, on, existing). for instance, (at, on, existing). for instance,
mi tawa tomoi go to house
literally means, i am going to house.similarly, similarly,
mi lon mai exist land
means, i am here (i exist on this land). means, i am here (i exist on this land).
note that prepositions do not and can nothave the `e` marker! have the `e` marker!
mi lon e mai exist [obj] land
here, the exist becomes a 使动用法, meaning"i make land exist" or "i create a world"! "i make land exist" or "i create a world"!quite an unusual statement... unless you'replaying minecraft. playing minecraft.
i should probably mention the effect of i should probably mention the effect ofreplacing `li` (or with `mi` or `sina`sentences, just adding) with `o` - turninga statement into a command. a statement into a command.
sina mokuyou eat(you are eating.)
sina o mokuyou command eat(oh you, eat!)
now is time to introduce linking sentences! now is time to introduce linking sentences!
"la" is the context modifier. it can be useda variety of ways, like
9 行未改动 = in the coming time, in the futurewile (require) sina (you) la = if you require so
or even full on sentences! or even full on sentences!
sina wile sona la sina o pali mute. sina wile sona la sina o pali mute.you want know -> you cmd work many(if you want to learn, then you shouldput in a lot of work.) put in a lot of work.)
taso is "but", and basically works likethe two-sentence la. the two-sentence la.
tan is a preposition for "because", like this:
mi la sina pona tan ni: sina suwime -> you good b/c this: you sweet(to me, you're good because you're sweet)
note how the "ni:" transition is requiredfor tan. mi la sina pona tan sina suwiis grammatically incorrect. is grammatically incorrect.
its 11:52, ill have to hurry up lolthere are two types of yes/no questions intoki pona - asking and checking. toki pona - asking and checking.
sina moku ala moku?you eat not eat?
pretty obvious how that works. pretty obvious how that works.
sina moku, ansm (short for anu seme)?you eat, or what
latter is just checking, showing theinclination of sina moku. it is not intendedto be rude. to be rude.
for "what / who / when" kind of questions, just use seme. for "what / who / when" kind of questions,just use seme.
sina pali e seme? you build >> what? sina pali e seme?you build >> what?
jan seme li pali? jan seme li pali?person what > build?
tenpo seme la sina pali? tenpo seme la sina pali?time what -> you build?
ok now im submitting, i think thats all thereis to toki pona except the vocab
oh and pronouns. im jan Nanpa. oh and pronouns. im jan Nanpa.
i guess you should check out wasona. i guess you should check out wasona.
**/```3 行未改动