2019蓝桥杯国赛递增序列
我的代码如下:import java.util.*;
public class Main {
public static int ans = 0;
public static char[][] a = new char[30][50];
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char[][] a = new char[30][50];
for (int i = 0; i < 30; i++) {
a[i] = scanner.nextLine().toCharArray();
}
for (int i = 0; i < 30; i++) {
for (int j = 0; j < 50; j++) {
heng(i, j);
shu(i,j);
xie(i,j);
}
}
System.out.print(ans);
}
public static void heng(int i,int j) {
for (int z = j+1; z < 50; z++) {
if (a[i][j]<a[i][z]) {
ans++;
}
}
}
public static void shu(int i,int j) {
for (int z = i+1; z < 30; z++) {
if (a[i][j]<a[z][j]) {
ans++;
}
}
}
public static void xie(int i,int j) {
for (int z = i+1; z < 30; z++) {
for (int k = j+1; k < 50; k++) {
if (a[i][j]<a[z][k]) {
ans++;
}
}
}
}
}
题目:对于一个字母矩阵,我们称矩阵中的一个递增序列是指在矩阵中找到两个字母,它们在同一行,同一列,或者在同一 4545 度的斜线上,这两个字母从左向右看、或者从上向下看是递增的。
例如,如下矩阵中
LANN
QIAO
copy
有LN、LN、AN、AN、IO、AO、LQ、AI、NO、NO、AQ、IN、ANLN、LN、AN、AN、IO、AO、LQ、AI、NO、NO、AQ、IN、AN 等 1313 个 递增序列。注意当两个字母是从左下到右上排列时,从左向右看和从上向下看 是不同的顺序。
对于下面的 3030 行 5050 列的矩阵,请问总共有多少个递增序列?
数据如下
VLPWJVVNNZSWFGHSFRBCOIJTPYNEURPIGKQGPSXUGNELGRVZAG
SDLLOVGRTWEYZKKXNKIRWGZWXWRHKXFASATDWZAPZRNHTNNGQF
ZGUGXVQDQAEAHOQEADMWWXFBXECKAVIGPTKTTQFWSWPKRPSMGA
BDGMGYHAOPPRRHKYZCMFZEDELCALTBSWNTAODXYVHQNDASUFRL
YVYWQZUTEPFSFXLTZBMBQETXGXFUEBHGMJKBPNIHMYOELYZIKH
ZYZHSLTCGNANNXTUJGBYKUOJMGOGRDPKEUGVHNZJZHDUNRERBU
XFPT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