C22P1 - Plastic Area

Do what it says. Beware that the answer may exceed $2^{31} - 1$, so you need to use a 64-bit integer type (long long in C++).

C22P2 - Plastic Permutation

Use the useful function and do what it says.

C22P3 - Plastic Matrix

If there is one even element and one odd element, add them together so they both become odd.
If there are two odd elements, add them together so they both become even.

Since there are at least 2 elements, the answer is always "Yes".

C22P4 - Plastic Rock

Method 1

Print any multiple of $n$ (except $n$), it has more factors than $ n $.

Method 2

Output any highly composite number greater than 69420.

C22P5 - Plastic Plastic

Filter by $p_i >= 69$, sort by $c_i$ ascending, then greedily buy in that order.

C22P6 - Plastic Palindrome

Subtask 1 (30%)

For every pairs of indices $(i, j)$ of the string $(i \lt j)$, check if $S[i..j]$ is a plastic palindrome.

Time Complexity: $ O(n^3) $

Subtask 2 (69%)

If we add the same character to the front and to the back of a palindrome, the resulting string is also a palindrome.
Expand outward from every character while it only contains the first $K$ charcters in the Latin alphabet, to count the number of palindromes centered at it.
Repeat the same for pairs of consecutive characters to count palindromes of even length.

Time Complexity: $ O(n^2) $

Full Solution (1%)

Apply one of the following:

We can see that this plastic contest is very plastic indeed.


六國破滅,非兵不利,戰不善,弊在賂秦。賂秦而力虧,破滅之道也。 或曰:六國互喪,率賂秦耶?曰:不賂者以賂者喪,蓋失強援,不能獨完。 故曰:弊在賂秦也。

秦以攻取之外,小則獲邑,大則得城。較秦之所得,與戰勝而得者,其實百倍; 諸侯之所亡,與戰敗而亡者,其實亦百倍。則秦之所大欲,諸侯之所大患,固不在戰矣。 思厥先祖父,暴霜露,斬荊棘,以有尺寸之地。子孫視之不甚惜,舉以予人,如棄草芥。 今日割五城,明日割十城,然后得一夕安寢。起視四境,而秦兵又至矣。 然則諸侯之地有限,暴秦之欲無厭,奉之彌繁,侵之愈急。故不戰而強弱勝負已判矣。 至于顛覆,理固宜然。古人云:「以地事秦,猶抱薪救火,薪不盡,火不滅。」此言得之。

齊人未嘗賂秦,終繼五國遷滅,何哉?與嬴而不助五國也。 五國既喪,齊亦不免矣。燕趙之君,始有遠略,能守其土,義不賂秦。 是故燕雖小國而后亡,斯用兵之效也。至丹以荊卿為計,始速禍焉。 趙嘗五戰于秦,二敗而三勝。后秦擊趙者再,李牧連卻之。 洎牧以讒誅,邯鄲為郡,惜其用武而不終也。 且燕趙處秦革滅殆盡之際,可謂智力孤危,戰敗而亡,誠不得已。 向使三國各愛其地,齊人勿附于秦,刺客不行,良將猶在 ,則勝負之數,存亡之理,當與秦相較,或未易量。

嗚呼!以賂秦之地,封天下之謀臣,以事秦之心,禮天下之奇才, 并力西向,則吾恐秦人食之不得下咽也。悲夫!有如此之勢, 而為秦人積威之所劫,日削月割,以趨于亡。為國者無使為積威之所劫哉!

夫六國與秦皆諸侯,其勢弱于秦,而猶有可以不賂而勝之之勢。 茍以天下之大,下而從六國破亡之故事,是又在六國下矣。