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
#include <iostream>
#include <message.h>
#include <set>
#include <vector>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <map>
#include <algorithm>
using namespace std;

const int size = 100504;
const int K = NumberOfNodes()-1;
int n, m;
char A[size], B[size];
pair<int, int> R[2][size];

void mainC() {
	for(int i = 0; i<=n; i++) R[0][i] = make_pair(i, 0);
	for(int i = 1; i<=n; i++) {
		for(int j = 1; j<=m; j++) {
			if(A[i] == B[j]) {
				R[1][j] = R[0][j-1];
			} else if(A[i] > B[j]){
				R[1][j] = min(R[0][j-1], min(R[1][j-1], R[0][j]));
				R[1][j].first++;
			} else {
				if(R[0][j-1] < R[1][j-1] && R[0][j-1] < R[0][j]) {
					R[1][j] = R[0][j-1];
					R[1][j].first++;
					R[1][j].second++;
				} else {
					R[1][j] = min(R[1][j-1], R[0][j]);
					R[1][j].first++;
				}
			}
		}
		R[1][0] = make_pair(i, 0);
		
		for(int j = 0; j<=m; j++) {
			//printf("%d ", R[0][j].first);
			R[0][j] = R[1][j];
		}
		//printf("\n");
	}
	printf("%d %d\n", R[0][m].first, R[0][m].second);
}

void otherC() {
	return;
}


int main() {
	scanf("%d %d\n", &n, &m);
	scanf("%s %s", A+1, B+1);
	if(MyNodeId() == 0) mainC();
	else otherC();
	return 0;
}