QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#28122#3251. 数正方体kWA 277ms45688kbJava84.7kb2022-04-12 09:31:362022-04-29 08:58:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-29 08:58:32]
  • 评测
  • 测评结果:WA
  • 用时:277ms
  • 内存:45688kb
  • [2022-04-12 09:31:36]
  • 提交

answer

import java.util.Arrays;
import java.util.Scanner;

public class Text {
    static char[][] maps = new char[1010][1010];
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);

        while (cin.hasNext()) {
            for (int i=0;i<1010;i++) {
                for (int j=0;j<1010;j++) {
                    Arrays.fill(maps[i], '.');
                }
            }
            int r = cin.nextInt();
            int c = cin.nextInt();
            cin.nextLine();
            for (int i=1;i<=r;i++) {
                String s = cin.nextLine();
                for (int j=0;j<c;j++) {
                    maps[i][j+1] = s.charAt(j);
                }
            }


            // find the cover x
            int flag = 1;
            int x_len = 0, y_len = 0, z_len = 0;
            for (int i=r;i>=1;i--) {
                boolean find = false;
                for (int j=flag;j<=c;) {
                    if (maps[i][j]=='+') {
                        find = true;
                        if (maps[i][j+1]=='-' && maps[i][j+2]=='-' && maps[i][j+3]=='-') {
                            x_len++;
                            j+=4;
                            flag = j;
                            continue;
                        }
                    }
                    j++;
                }
                if (find) flag+=2;
            }

            // find the cover z
            flag = r;
            for (int j=c;j>=1;j--) {
                for (int i=flag;i>=1;) {
                    if (maps[i][j]=='+') {

                        if (i-2<0) {
                            i--;
                            continue;
                        }
                        if (maps[i-1][j]=='|' && maps[i-2][j]=='|') {
                            z_len++;
                            i-=3;
                            flag = i;
                            continue;
                        }
                    }
                    i--;
                }
            }

            for (int i=1;i<=c;i++) {
                if (maps[1][i]=='+') {
                    flag = i;
                    break;
                }
            }
//			System.out.println("flag =" + flag);
            for (int i=1;i<=r;i++) {
                for (int j=flag;j>=1;) {

                    if(maps[i][j]=='+') {
//						System.out.println(i+","+j);
                        if (j-2<0) {j--;continue;}
                        if (maps[i+1][j-1] == '/' && maps[i+2][j-2]=='+') {
                            y_len++;
                            j-=2;
                            flag = j;
                            continue;
                        }
                    }
                    j--;
                }
            }

//			int[][] matrix = new int[y_len+1][x_len+1];
//			Arrays.fill(matrix , 0);
//
//			matrix[1][1] = z_len;
//			for (int i=2;i<=x_len;i++) {
//
//			}


            // deal with top area
            for (int i=1;i<=y_len*2-1;i+=2) {
//				System.out.println(i);
                for (int k=1;k<=c;k++) {
                    if (maps[i][k]=='+') {
                        flag = k;
                        break;
                    }
                }
                // 1 5 9 13
                for (int j=flag;j<=4*x_len+1 ;j+=4) {
//					System.out.println();
                    if (maps[i][j+4]!='+')
                        maps[i][j+4] = '*';

                    if (maps[i+2][j+2]!='+')
                        maps[i+2][j+2] = '*';

                    if (maps[i+2][j-2]!='+')
                        maps[i+2][j-2] = '*';
                }
            }
            // deal with the commmon area

            for (int i=r;i>=r - z_len*3+2;i-=3) {

                for (int j=1;j<=4*x_len-3 ;j+=4) {
//					System.out.println(j+ ",");
//					System.out.println();
                    if (maps[i][j+4]!='+')
                        maps[i][j+4] = '*';

                    if (maps[i+3][j+4]!='+')
                        maps[i+3][j+4] = '*';

                    if (maps[i+3][j]!='+')
                        maps[i+3][j] = '*';


                }
            }
            int cnt = 0;
            for (int i=1;i<=r;i++) {
                for (int j=1;j<=c;j++) {
                    if (maps[i][j]=='*')
                        cnt++;
                }
            }
//			System.out.println(cnt);
            // end of this

//			for (int i=1;i<=r;i++) {
//				for (int j=1;j<=c;j++) {
//					System.out.print(maps[i][j]);
//				}
//				System.out.println();
//
//			}

            System.out.println(x_len * y_len * z_len - cnt + 1);
        }
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 277ms
memory: 45688kb

input:

371 259
......................................................................+---+---+....................................................................................................................................................................................
...................................

output:

161015

result:

wrong answer 1st lines differ - expected: '84826', found: '161015'