变牛的最快方法 贪心只选1 2操作 拿三分之二分
作者:
徐枭翔
,
2024-08-03 21:57:24
,
所有人可见
,
阅读 2
https://pintia.cn/problem-sets/1556843855285559296/exam/problems/type/7?problemSetProblemId=1556843936151740419&page=0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef vector<long long> VI;
#define int long long
#define INF 0x3f3f3f3f
#define endl '\n'
#define N 200010
const int mod = 1e9 + 7;
void solve() {
vector<int> a, b;
int x, y;
cin >> x;
while (x != -1) {
a.push_back(x);
cin >> x;
}
int n = a.size();
cin >> y;
while (y != -1) {
b.push_back(y);
cin >> y;
}
int m = b.size();
int res = max (n, m);
vector<int> ans;
for (int i = 0; i < min(a.size(), b.size()); i ++) {
if (a[i] == b[i]) {
res --;
ans.push_back(2);
} else ans.push_back(1);
}
int len = abs(n - m);
for (int i = 1; i <= len; i ++) {
if (n > m) ans.push_back(0);
else ans.push_back(3);
}
cout << res << endl;
for(auto t : ans)cout << t;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}