Submission #75260767


Source Code Expand

import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        char grid[][] = new char[a][b];
        
        for (int i = 0; i < a; i++) {
            String s = sc.next();
            for (int j = 0; j < b; j++) {
                grid[i][j] = s.charAt(j);
            }
        }
        
        int count=0;
        
        for(int h1=0;h1<a;h1++){
            for(int h2=h1;h2<a;h2++){
                for(int w1=0;w1<b;w1++){
                    for(int w2=w1;w2<b;w2++){
                        boolean ok = true;
                        for (int i = h1; i <= h2; i++) {
                            for (int j = w1; j <= w2; j++) {
                                int x = h1 + h2 - i;
                                int y = w1 + w2 - j;
                                if (grid[i][j] != grid[x][y]) {
                                    ok = false;
                                    break;
                                }
                            }
                            if(ok==false){
                                break;
                            }
                        }
                        if (ok) {
                            count++;
                    
                        }
                    }
                }
            }
        }
        System.out.print(count);
    }
}

Submission Info

Submission Time
Task B - Spiral Galaxy
User renu_
Language Java24 (OpenJDK 24.0.2)
Score 200
Code Size 1494 Byte
Status AC
Exec Time 76 ms
Memory 40972 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 13
Set Name Test Cases
Sample sample00.txt, sample01.txt
All sample00.txt, sample01.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt
Case Name Status Exec Time Memory
sample00.txt AC 76 ms 40332 KiB
sample01.txt AC 75 ms 40652 KiB
testcase00.txt AC 72 ms 40404 KiB
testcase01.txt AC 72 ms 40472 KiB
testcase02.txt AC 74 ms 40220 KiB
testcase03.txt AC 74 ms 40772 KiB
testcase04.txt AC 76 ms 40972 KiB
testcase05.txt AC 73 ms 40828 KiB
testcase06.txt AC 73 ms 40648 KiB
testcase07.txt AC 75 ms 40848 KiB
testcase08.txt AC 73 ms 40352 KiB
testcase09.txt AC 74 ms 40860 KiB
testcase10.txt AC 74 ms 40552 KiB