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
#include <iostream>

using namespace std;

bool zgrzyt(int i, int j, int * distance){
	if(i < j && distance[i] > distance[j] || i > j && distance[i] < distance[j]){
		return true;
	}
	return false;
}

//UwU
int n, sn, per;

void stuffForK(int * distance, int * meSoldiers, int index, int lastSoldier, int k, int & min){
	if(k <= 0){
		
		int tmin = 0;
		for(int i = 0; i < sn; ++i){
			for(int j = i + 1; j < sn; ++j){
				if(zgrzyt(meSoldiers[i], meSoldiers[j], distance)) tmin++;
			}
		}
		
		if(tmin == min) per++;
		else if(tmin < min){
			min = tmin;
			per = 1;
		}
		
		return;
	}
	
	for(int i = lastSoldier + 1; i < n; ++i){
		meSoldiers[index] = i;
		stuffForK(distance, meSoldiers, index + 1, i, k - 1, min);
	}
}

void dostuff(int * distance, int & n){
	for(int k = 2; k < n; ++k){
		int meSoldiers[k];
		
		int min = n*n;
		per = 0;
		sn = k;
		stuffForK(distance, meSoldiers, 0, -1, k, min);
		
		cout << min << ' ' << per << endl;
	}
}

int main(){
	
	cin >> n;
	int distance[n];
	for(int i = 0; i < n; ++i){
		cin >> distance[i];
	}
	
	cout << "0 " << n << endl;
	dostuff(distance, n);
	int min = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			if(zgrzyt(i, j, distance)) min++;
		}
	}
	cout << min << " 1" << endl;
	
	return 0;
}