A9058 | Yaroslav and Two Strings
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Yaroslav thinks that two strings $s$ and $w$ , consisting of digits and having length $n$ are non-comparable if there are two numbers, $i$ and $j$ $(1<=i,j<=n)$ , such that $s_{i}>w_{i}$ and $s_{j}<w_{j}$ . Here sign $s_{i}$ represents the $i$ -th digit of string $s$ , similarly, $w_{j}$ represents the $j$ -th digit of string $w$ .
A string's template is a string that consists of digits and question marks ("?").
Yaroslav has two string templates, each of them has length $n$ . Yaroslav wants to count the number of ways to replace all question marks by some integers in both templates, so as to make the resulting strings incomparable. Note that the obtained strings can contain leading zeroes and that distinct question marks can be replaced by distinct or the same integers.
Help Yaroslav, calculate the remainder after dividing the described number of ways by $1000000007$ $(10^{9}+7)$ .
A string's template is a string that consists of digits and question marks ("?").
Yaroslav has two string templates, each of them has length $n$ . Yaroslav wants to count the number of ways to replace all question marks by some integers in both templates, so as to make the resulting strings incomparable. Note that the obtained strings can contain leading zeroes and that distinct question marks can be replaced by distinct or the same integers.
Help Yaroslav, calculate the remainder after dividing the described number of ways by $1000000007$ $(10^{9}+7)$ .
输入格式
The first line contains integer $n$ $(1<=n<=10^{5})$ — the length of both templates. The second line contains the first template — a string that consists of digits and characters "?". The string's length equals $n$ . The third line contains the second template in the same format.
输出格式
In a single line print the remainder after dividing the answer to the problem by number $1000000007$ $(10^{9}+7)$ .
输入输出样例
输入 #1
2 90 09
输出 #1
1
输入 #2
2 11 55
输出 #2
0
输入 #3
5 ????? ?????
输出 #3
993531194
The first test contains no question marks and both strings are incomparable, so the answer is $1$ .
The second test has no question marks, but the given strings are comparable, so the answer is $0$ .
The second test has no question marks, but the given strings are comparable, so the answer is $0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted