Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
Created March 26, 2015 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsrinivas/546ca7fe7e624fab615a to your computer and use it in GitHub Desktop.
Save zsrinivas/546ca7fe7e624fab615a to your computer and use it in GitHub Desktop.
codeforces #297 B. Pasha and String
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# pylint: disable=invalid-name,missing-docstring,bad-builtin
def main():
s = list(raw_input())
n = len(s)
m = int(raw_input())
arr = map(int, raw_input().split())
arr.sort()
k = 0
for x in xrange(n // 2):
while k < m and arr[k] - 1 <= x:
k += 1
if k % 2:
s[x], s[n - x - 1] = s[n - x - 1], s[x]
print ''.join(s)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment