Kotlin Heroes: Episode 9 (Unrated, T-Shirts + Prizes!)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1910 Kotlin Heroes: Episode 9 (Unrated, T-Shirts + Prizes!) FINISHED False 9000 34874663 Dec. 11, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 695 ) B Security Guard PROGRAMMING *special greedy

B'Monocarp is a security guard in Berland State University. Every day, he tracks how many people and at what time enter and leave the university. He writes this information down as follows: At the beginning of the current day, there are no people at the university, except for Monocarp. During the day, Monocarp wrote out a sequence s . The characters in s are listed in the order Monocarp wrote them. Suddenly, Monocarp 's boss decided to check his work. Unfortunately, Monocarp is a bit careless. So, the sequence s that he wrote might be impossible. For example, the sequence "+--" can 't happen, since it represents a scenario when one person enters the university and two leave. Before his boss starts checking the sequence, Monocarp has the time to swap at most one pair of characters in it. Can he do it in such a way that the resulting sequence is plausible? Note that if the given sequence is already plausible, Monocarp doesn 't have to swap anything. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The only line of each test case contains a single string s ( 1 <= |s| <= 3 cdot 10^5 ), consisting only of characters '+ ' and/or '- '. A plus sign '+ ' represents a person entering the university. A minus sign '- ' represents a person leaving the university. The sum of all |s| over all test cases doesn 't exceed 3 cdot 10^5 . For each test case, print an answer. If it 's impossible to swap at most one pair of characters so that the resulting sequence is plausible, print -1. Otherwise, print two integers. If you swap one pair of characters, print two distinct integers from 1 to n -- the indices of characters to swap. If you don 't swap, print one integer from 1 to n twice -- swap a character with itself. If there are multiple answers, print any of them. '...

Tutorials

123261

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
236792487 tabr B Dec. 11, 2023, 2:46 p.m. OK Kotlin 1.7 TESTS 8 295 2355200
236793521 MagentaCobra B Dec. 11, 2023, 2:50 p.m. OK Kotlin 1.7 TESTS 8 296 1433600
236792348 pashka B Dec. 11, 2023, 2:45 p.m. OK Kotlin 1.7 TESTS 8 311 5632000
236792530 uwi B Dec. 11, 2023, 2:46 p.m. OK Kotlin 1.7 TESTS 8 311 6758400
236795927 Lucina B Dec. 11, 2023, 3:02 p.m. OK Kotlin 1.7 TESTS 8 311 10649600
236827686 Sumitsingh7 B Dec. 11, 2023, 7:24 p.m. OK Kotlin 1.7 TESTS 8 327 4915200
236802969 tienloc1511 B Dec. 11, 2023, 3:45 p.m. OK Kotlin 1.7 TESTS 8 327 6144000
236792967 Hakiobo B Dec. 11, 2023, 2:48 p.m. OK Kotlin 1.7 TESTS 8 343 1433600
236793422 alexey.enkov B Dec. 11, 2023, 2:50 p.m. OK Kotlin 1.7 TESTS 8 343 28774400
236797990 cftauros B Dec. 11, 2023, 3:13 p.m. OK Kotlin 1.7 TESTS 8 358 5120000
236793144 Spheniscine B Dec. 11, 2023, 2:48 p.m. OK Kotlin 1.9 TESTS 8 311 22937600
236795883 Yomgaq B Dec. 11, 2023, 3:02 p.m. OK Kotlin 1.9 TESTS 8 327 10547200
236793929 Eslam_Ahmed B Dec. 11, 2023, 2:52 p.m. OK Kotlin 1.9 TESTS 8 342 5632000
236799338 God_Man B Dec. 11, 2023, 3:22 p.m. OK Kotlin 1.9 TESTS 8 342 7884800
236797527 Valera_Grinenko B Dec. 11, 2023, 3:11 p.m. OK Kotlin 1.9 TESTS 8 342 10956800
236796173 MateuszPietrzak B Dec. 11, 2023, 3:03 p.m. OK Kotlin 1.9 TESTS 8 343 409600
236794620 nuip B Dec. 11, 2023, 2:55 p.m. OK Kotlin 1.9 TESTS 8 358 1740800
236809828 _Anton B Dec. 11, 2023, 4:35 p.m. OK Kotlin 1.9 TESTS 8 358 3788800
236792390 DeadlyPillow B Dec. 11, 2023, 2:45 p.m. OK Kotlin 1.9 TESTS 8 358 9932800
236803370 pelmen228 B Dec. 11, 2023, 3:48 p.m. OK Kotlin 1.9 TESTS 8 373 14028800

remove filters

Back to search problems