CF1120B Once in a casino

题目描述

## 题目大意 给定两个长度都为n$(1\leq n\leq 10^5)$的数字串A和B,你可以执行若干次操作,每次操作是将相邻的两个位置+1或-1,要求 - 不能对数字串以外的位置进行操作 - 操作中每个数字都必须在$[0,9]$中。 - 首位数字不能为0 求把A变成B所执行的最小操作数c,并输出前$\min(c,10^5)$个操作,无解输出-1。

输入格式

第一行一个正整数n表示A和B的长度。 接下来有两行,每行一个长度为n的数字串表示A和B。

输出格式

如果不可能把A变成B,输出-1。 否则第一行输出最小操作数c。 接下来输出$num=\min(c,10^5)$行,表示前num个操作,第 i 行输出两个整数$d_i,s_i(1\leq l\leq n-1,s=\pm 1)$,表示第 i 个操作将$a_{d_i}$和$a_{d_i+1}$加上$s_i$。

说明/提示

In the first example, we can make a +1 operation on the two first digits, transforming number $ \textbf{22}3 $ into $ \textbf{33}3 $ , and then make a -1 operation on the last two digits, transforming $ 3\textbf{33} $ into $ 3\textbf{22} $ . It's also possible to do these operations in reverse order, which makes another correct answer. In the last example, one can show that it's impossible to transform $ 35 $ into $ 44 $ .