Submission #75246949
Source Code Expand
#include <bits/stdc++.h>
#include <atcoder/all>
#define LF putchar('\n')
typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353LL; //1000000007LL;
static const LLONG INF_NUM = 1e18;
static const int CH_KIND = 'z' - 'a' + 1;
template<class _T> static void get(_T& a) {
std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
if (a < (_T)0) {
a *= (_T)-1;
}
return a;
}
template <class _T> static _T tp_pow(int x, int exp)
{
_T ans = 1;
_T base = x;
while (exp > 0) {
if (exp & 1) {
ans = (ans * base);
}
base = (base * base);
exp >>= 1;
}
return ans;
}
static void task();
int main()
{
task();
fflush(stdout);
return 0;
}
static void task()
{
int H, W;
get(H, W);
std::vector<std::string> grid(H);
for (int h = 0; h < H; h++) {
get(grid[h]);
}
int ans = 0;
for (int h1 = 0; h1 < H; h1++) {
for (int w1 = 0; w1 < W; w1++) {
for (int h2 = h1; h2 < H; h2++) {
for (int w2 = w1; w2 < W; w2++) {
bool ok = true;
for (int i = h1; i <= h2; i++) {
for (int j = w1; j <= w2; j++) {
if ((h1 + h2 - i >= H) || (w1 + w2 - j >= W)) ok = false;
if (grid[i][j] != grid[h1 + h2 - i][w1 + w2 - j]) ok = false;
if (!ok) break;
}
}
if (ok) ans++;
}
}
}
}
printf("%d\n", ans);
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Spiral Galaxy |
| User | takumat |
| Language | C++23 (GCC 15.2.0) |
| Score | 200 |
| Code Size | 1810 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3848 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| 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 | 1 ms | 3848 KiB |
| sample01.txt | AC | 1 ms | 3720 KiB |
| testcase00.txt | AC | 1 ms | 3756 KiB |
| testcase01.txt | AC | 1 ms | 3696 KiB |
| testcase02.txt | AC | 1 ms | 3768 KiB |
| testcase03.txt | AC | 1 ms | 3720 KiB |
| testcase04.txt | AC | 1 ms | 3604 KiB |
| testcase05.txt | AC | 1 ms | 3604 KiB |
| testcase06.txt | AC | 1 ms | 3604 KiB |
| testcase07.txt | AC | 1 ms | 3768 KiB |
| testcase08.txt | AC | 1 ms | 3604 KiB |
| testcase09.txt | AC | 1 ms | 3848 KiB |
| testcase10.txt | AC | 1 ms | 3680 KiB |