#1008. 翻转和反转
翻转和反转
说明
仔仔 有一个长度为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>01</mn></mrow></semantics></math>01 串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s,第 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 位表示为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>si。他要操作 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>q 次,每次操作的内容如下:
-
<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold">1</mtext></mrow></semantics></math>1,将 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>01</mn></mrow></semantics></math>01 串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s 翻转,即将字符串中的字符顺序颠倒过来。例如 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s 串原来是
10010
,翻转(颠倒)后变为01001
。 -
<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold">2</mtext></mrow></semantics></math>2,将 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>01</mn></mrow></semantics></math>01 串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s 反转,即逐位取反。对于每个 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i(<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mi>�</mi></mrow></semantics></math>1≤i≤n),如果 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub><mo>=</mo><mn>0</mn></mrow></semantics></math>si=0,则令 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>si 变成 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow></semantics></math>1;否则令 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>si 变成 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn></mrow></semantics></math>0。
请你告诉 仔仔 操作 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>q 次后的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>01</mn></mrow></semantics></math>01 串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s。
输入格式
输入共三行。
第一行两个整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo separator="true">,</mo><mi>�</mi></mrow></semantics></math>n,q。
第二行一个长度为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>n 的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>01</mn></mrow></semantics></math>01 串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s。
第三行一个长度为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>q 的字符串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>w,其中 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>wi 表示第 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 次操作的内容。如果 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub><mo>=</mo><mn>1</mn></mrow></semantics></math>wi=1,表示进行翻转操作;如果 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mi>�</mi></msub><mo>=</mo><mn>2</mn></mrow></semantics></math>wi=2,表示进行反转操作。
输出格式
输出操作 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>q 次后的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>01</mn></mrow></semantics></math>01 串 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>s。
样例
7 10
1001100
1222121222
1100110
提示
数据规模与约定
- 对于 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50</mn><mi mathvariant="normal">%</mi></mrow></semantics></math>50% 的数据,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>3</mn></msup></mrow></semantics></math>1≤n≤103,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>3</mn></msup></mrow></semantics></math>1≤q≤103。
- 对于 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>100</mn><mi mathvariant="normal">%</mi></mrow></semantics></math>100% 的数据,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>5</mn></msup></mrow></semantics></math>1≤n≤105,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>1</mn><msup><mn>0</mn><mn>5</mn></msup></mrow></semantics></math>1≤q≤105。