Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <string.h>
- using namespace std;
- int main() {
- string s,a;
- int sum1 = 0, sum2 = 0;
- int ans = 0;
- int n = 0;
- char d[10000][2];
- cin >> a;
- cin >> s;
- bool k=0;
- for(int i = 0; i < a.size(); i++){
- for(int j = 0; j < i; j ++){
- if(a[i] == d[j][0] || a[i] == d[j][1] || s[i] == d[j][0] || s[i] == d[j][1]){
- k = 1;
- }
- if((s[i] == d[j][1] && a[i] != d[j][0]) || (s[i] != s[j] && a[i] == a[j]) || (a[i] != a[j] && s[i] == s[j]) || (s[i] != s[j] && a[i] == a[j])){
- cout << -1;
- return 0;
- }
- }
- if(a[i] != s[i] && k == 0){
- ans++;
- d[n][0] = s[i];
- d[n][1] = a[i];
- n++;
- }
- k = 0;
- }
- cout << n << endl;
- for(int i = 0; i < n; i++){
- cout << d[i][1] << " " << d[i][0] << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment