This question is as adhoc as it gets. Some people are gonna have a hard time digesting this(me included). I was trying some stuff using triangular numbers and having strings like “abcd…z”. I had a feeling the actual solution was much simpler. Kudos to the author.
Appeal to change the contest name to AdHoc CC Contest ;-;
During Contest, All I believe was this is a dp problem and I was finding some O(nlogn) solution. After this editorial, I am like
Umm, I just tried this, but it gave me a WA, I think there’s something wrong with the checker.
Here is the submission
EDIT: Darn it, we had to output the string length as well, I Iiterally worked on this problem for 2 hours, and didn’t notice that we had to output the length as well, sorry folks my bad.
should i laugh or cry after seeing this solution cant judge please help!!
And 7*n is provided Just to distract us! (My all thinking starts from number 7, I make different combination of a string having the length multiple of 7)
From aaaa....bbbbb You can choose 0-D occurrence of each character.
So number of distinct Substrings is (D+1)(D+1) - 1.
-1 is because of the empty string.
Number of Palindromes in aaa...a is n\choose2 +n.
Are they rejudging this problem I see a few submissions in being judged right now ?
This along with GOLMINE
You must remember that problem right? XD
Yup! still haunts me
@rajarshi_basu will practice make me able to solve such problems?I had guessed the pattern to be like this but got stuck on how to count number of substrings.
Any suggestions about how to improve Sir?
Aaaree bro, I had guessed a pattern of such kind but me so stupid could not count number of distinct substrings
U are not alone buddy
Last test case has changed during contest without any notification/announcement. Previously the input was 63 and then changed to 60.
Bad day after todays CC and CF contests
WTF ,i spent so much time in this and still can’t figure it out during contest i thought it’s pretty tough question but after seeing the solution i think i am way poor in thinking and coding
Experiments with inputs and observation on them.
Instead of directly calculating it…you can also count it using map bro…
int ass(string s) { int n = s.size(); map<string, int> cnt; int pal = 0; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { int l = j - i + 1; string t = s.substr(i, l); bool f = true; for (int k = 0; k < l; k++) { if (t[k] != t[l - k - 1]) f = false; } cnt[t]++; if (f) pal++; } } return cnt.size() - pal; }
nnoo is not palindromic
okey got the error silly mistake and thanks