比赛 |
EYOI与SBOI开学欢乐赛10th |
评测结果 |
WWAWWAWWWW |
题目名称 |
01串 |
最终得分 |
20 |
用户昵称 |
HeSn |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-10-10 21:30:27 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 20010;
int n, xi, yi, sum1, sum2, ans;
string s1, s2;
signed main() {
freopen("zerone.in", "r", stdin);
freopen("zerone.out", "w", stdout);
cin >> n >> xi >> yi >> s1 >> s2;
for(int i = 0; i < n; i ++) {
sum1 += s1[i] == '1';
sum2 += s2[i] == '1';
}
if(sum1 != sum2) {
cout << -1;
return 0;
}
if(yi <= xi) {
sum1 = 0;
for(int i = 0; i < n; i ++) {
if(s1[i] == '1' && s2[i] != '1') {
sum1 ++;
}
}
cout << yi * sum1;
return 0;
}
int pos = 0;
for(int i = 0; i < n; i ++) {
if(s1[i] == '0') {
continue;
}
for(int j = pos; j < n; j ++) {
if(s2[j] == '1') {
ans += min(yi, xi * abs(j - i));
// cout << ans << ' ' << i << ' ' << j << endl;
pos = j + 1;
break;
}
}
}
cout << ans;
return 0;
}