1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include "message.h"
using namespace std;
#define ll long long
#define ld long double
#define vi vector<int>
#define vii vector<pair<int, int> >
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define mini(a,b) a=min(a,(b))
#define maxi(a,b) a=max(a,(b))
#define RE(i,n) for(int i=0,_n=(n);i<_n;++i)
#define RI(i,n) for(int i=1,_n=(n);i<=_n;++i)
#define h first
#define id second
const int inf=1e9+5, nax = 1e5 + 5;

int n, m;
char s1[nax], s2[nax];
pii t[nax];

int main()
{
	ios_base::sync_with_stdio(0); 		// eighfivwrlsfdljqhwfkj zabierz to klsfjgbwilrjgfdsojn
	
	cin >> n >> m;
	cin >> s1 >> s2;
	
	int ja = MyNodeId();
	int ile = NumberOfNodes();
	
	RE(i, nax) t[i] = mp(inf, inf);
	
	if(ja) {
		RE(i, n) {
			if(i % 200 == 0)
				Receive(ja - 1);
			
			pii x, y;
			x.first = GetInt(ja - 1); x.second = GetInt(ja - 1);
			
			int dol = ja * m / ile, gora = (ja + 1) * m / ile;
			for(int poz = dol + 1; poz <= min(gora, m - 1); ++poz) {
				y = min(t[poz], x);
				y.first += 1;
				int roz = ((int) s2[poz]) - ((int) s1[i]);
				if(roz > 0) t[poz - 1].second += 1;
				else if(roz != 0) t[poz - 1].first += 1;
				mini(y, t[poz - 1]);
				t[poz - 1] = x;
				x = y;
			}
			if(ja == ile - 1) t[m - 1] = x;
			else {
				PutInt(ja + 1, x.first);
				PutInt(ja + 1, x.second);
				if((i+1)%200 == 0 || i == n - 1)
					Send(ja + 1);
			}
		}
		if(ja == ile - 1)
			cout << t[m - 1].first << " " << t[m - 1].second;
	}			
	
	else {
		RE(i, n) {
			
			pii x, y;
			x = mp(i + 1, 0);
			
			int dol = ja * m / ile, gora = (ja + 1) * m / ile;
			for(int poz = dol + 1; poz <= min(gora, m - 1); ++poz) {
				y = min(t[poz], x);
				y.first += 1;
				int roz = ((int) s2[poz]) - ((int) s1[i]);
				if(roz > 0) t[poz - 1].second += 1;
				else if(roz != 0) t[poz - 1].first += 1;
				mini(y, t[poz - 1]);
				t[poz - 1] = x;
				x = y;
			}
			if(ja == ile - 1) t[m - 1] = x;
			else {
				PutInt(ja + 1, x.first);
				PutInt(ja + 1, x.second);
				if((i+1)%200 == 0 || i == n - 1)
					Send(ja + 1);
			}
		}
		if(ja == ile - 1)
			cout << t[m - 1].first << " " << t[m - 1].second;
	}
				
	return 0;
}