想了半天都不明白为什么是错了答案,不是超时
import java.util.*;
public class Main{
static int n ,m, N = 60, cnt;
static String g[][] = new String[N][N];
static double a[][] = new double[N][N];
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
for(int i=0;i<N ;i++) Arrays.fill(a[i], -1);
n = sc.nextInt();
m = sc.nextInt();
sc.nextLine();
for(int i=0;i<n;i++){
String t[] = sc.nextLine().split(" ");
for(int j=0;j<m;j++){
g[i][j] = t[j];
if(t[j].charAt(0) < 'A' )
a[i][j] = Double.parseDouble(t[j]);
else {
cnt++;
}
}
}
while(true){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(a[i][j] == -1){
String s = g[i][j];
String method = s.substring(0,3);
String script[] = s.substring(4,s.length()-1).split(":");
String up[] = script[0].split(",");
int x1 = Integer.parseInt(up[0]);
int y1 = Integer.parseInt(up[1]);
String down[] = script[1].split(",");
int x2 = Integer.parseInt(down[0]);
int y2 = Integer.parseInt(down[1]);
boolean flag = false;
double sum = 0, count = 0;;
for(int x = x1-1; x < x2 ; x ++){
for(int y = y1-1; y < y2; y ++){
sum += a[x][y];
count += 1;
if(a[x][y] == -1){
flag = true;
break ;
}
}
}
if(flag) continue ;
double avg = sum / count;
if("SUM".equals(method)){
a[i][j] = sum;
}else if("AVG".equals(method)){
a[i][j] = avg ;
}else {
sum = 0;
for(int x = x1-1; x < x2 ; x ++){
for(int y = y1-1; y < y2; y ++){
sum += (a[x][y] - avg) * (a[x][y] - avg);
}
}
a[i][j] = Math.sqrt(sum * 1.0 / count);
}
cnt --;
if(cnt == 0){
print();
return ;
}
}
}
}
}
}
static void print(){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
System.out.printf("%.2f ",a[i][j]);
}
System.out.println();
}
}
}