Skip to content

Patch 1#6084

Open
lems9520138 wants to merge 11 commits intocpinitiative:masterfrom
lems9520138:patch-1
Open

Patch 1#6084
lems9520138 wants to merge 11 commits intocpinitiative:masterfrom
lems9520138:patch-1

Conversation

@lems9520138
Copy link
Copy Markdown
Contributor

Place an "x" in the corresponding checkbox if it is done or does not apply to this pull request.

  • [x ] I have tested my code.
  • [x ] I have added my solution according to the steps here.
  • [x ] I have followed the code conventions mentioned here.
    • I understand that if it is clear that I have not attempted to follow these conventions, my PR will be closed.
    • If changes are requested, I will re-request a review after addressing them.
  • [x ] I have linked this PR to any issues that it closes.

Comment on lines +511 to +523

{
"uniqueId": "usaco-1445",
"name": "It's Mooin' Time",
"url": "https://usaco.org/index.php?page=viewproblem2&cpid=1445",
"source": "Bronze",
"difficulty": "Easy",
"isStarred": false,
"tags": ["Complete Search"],
"solutionMetadata": {
"kind": "internal"
}
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not already somewhere in guide? i would expect it to be at least

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought it was but ig not, its in monthlies but i couldnt find metadata anywhere

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://usaco.guide/bronze/intro-sets#problem-usaco-1445 :P

always good to do a search of the repo first for this typa thing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh 😭 i did not know you could do that mb.
Wait why is this hard??? Ig it needs maps knowledge but does that constitute it for a hard??


## Implementation

**Time Complexity:** $\mathcal{O}(26N)$
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use a constant $C$ instead of 26? cuz usually we don't include the pure numbers in time complexity, but it is fairly significant here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where would I write C = 26, representing the numbers of letters.

Ig pure numbers is bad but i js thought since it alr kinda represents the # of letters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe mention in the explanation that while the time is technically O(N), the factor of 26 is significant

// Test each possible modifications plus the original character that was in the
// string This makes sure that the original counts of the string is restored
// afterwards
for (char mod = 'a'; mod <= 'z' + 1 && !done; mod++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like this part of the code could be slightly more 'elegant' (e.g. why is done here? can't you just reset to original after the loop?)

in a similar vein, could loop over i - 2 to i, tho it doesn't matter too much

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wym loop over i - 2 to i??

I can modify my comment to explain it better or recode it.

The main rational behind it was that it was shorter code... :| instead of having to manually test the regular posiiton, each modification basically does the modification so i could test every single modification + the original one which would modify it back to the original position.

If this is better, i could also rewrite the for loop so that it does every character once, (starts at letter + 1 in ascii, loops 26 times and do % 26 to get the current letter)

Copy link
Copy Markdown
Contributor

@eysbutno eysbutno Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok not necessarily looped but a lot of code is kind of repeated

edi code is pretty clean in this regard: https://usaco.org/current/data/sol_prob3_bronze_dec24.html

Co-authored-by: Justin Ji <68484800+eysbutno@users.noreply.github.com>
@lems9520138
Copy link
Copy Markdown
Contributor Author

Still need to fix the explanation a bit, not perfect but lmk if its a little bit clearer.

Added logic to update character frequencies and insert answers based on conditions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants