Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
Created July 29, 2015 18:37
Show Gist options
  • Select an option

  • Save zsrinivas/763c66fa3793b1285557 to your computer and use it in GitHub Desktop.

Select an option

Save zsrinivas/763c66fa3793b1285557 to your computer and use it in GitHub Desktop.
spoj ins14c
#!/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