parent
99f721549e
commit
79aa3d9ae7
@ -1,30 +1,48 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 31;
|
||||
char a[N][N];
|
||||
int n, m, cnt;
|
||||
const int INF = 0x3f3f3f3f;
|
||||
const int N = 110;
|
||||
double a[N];
|
||||
int n;
|
||||
int f1[N], f2[N];
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < m; j++)
|
||||
cin >> a[i][j];
|
||||
for (int e = 2; e < min(m, n); e++) {
|
||||
for (int i = 0; i <= n - e; i++) {
|
||||
for (int j = 0; j <= m - e; j++) {
|
||||
bool f = true;
|
||||
for (int x = 0; x < e; x++) {
|
||||
for (int y = 0; y < e; y++) {
|
||||
if (a[i][j] != a[i + x][j + y]) {
|
||||
f = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!f) break;
|
||||
}
|
||||
if (f) cnt++;
|
||||
}
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i];
|
||||
for (int i = 1; i <= n; i++) {
|
||||
f1[i] = 1;
|
||||
for (int j = 1; j < i; j++)
|
||||
if (a[i] > a[j]) f1[i] = max(f1[i], f1[j] + 1);
|
||||
}
|
||||
for (int i = n; i >= 1; i--) {
|
||||
f2[i] = 1;
|
||||
for (int j = 1; j < i; j++)
|
||||
if (a[i] > a[j]) f2[i] = max(f1[i], f1[j] + 1);
|
||||
}
|
||||
bool flag = true;
|
||||
for (int i = 1; i <= n; i++)
|
||||
if (f1[i] != 1) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
if (flag) {
|
||||
cout << -1 << endl;
|
||||
exit(0);
|
||||
}
|
||||
flag = true;
|
||||
for (int i = 1; i <= n; i++)
|
||||
if (f2[i] != 1) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
if (flag) {
|
||||
cout << -1 << endl;
|
||||
exit(0);
|
||||
}
|
||||
int mx = -1;
|
||||
for (int i = 1; i <= n; i++){
|
||||
int t = f1[i] + f2[i];
|
||||
mx = max(mx, t);
|
||||
}
|
||||
cout << cnt;
|
||||
cout << n - mx + 1;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue