Created
July 29, 2015 18:37
-
-
Save zsrinivas/763c66fa3793b1285557 to your computer and use it in GitHub Desktop.
spoj ins14c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- encoding: utf-8 -*- | |
| # pylint: disable=invalid-name,missing-docstring,bad-builtin | |
| from sys import stdin | |
| def main(): | |
| dstream = iter(stdin.read().split()) | |
| for _ in xrange(int(next(dstream))): | |
| n, k, play = next(dstream), next(dstream), next(dstream) | |
| play, turns = bytearray(play), int(n) - int(k) | |
| while turns > 0: | |
| for x in xrange(min(turns, 2)): | |
| play[play.find('10'[x]) if play.find('10'[x]) >= 0 else play.find('01'[x])] = ' ' | |
| turns -= 2 | |
| print play.replace(' ', '') | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment