結果
| 問題 | No.3428 Palindromic Path (Easy) |
| コンテスト | |
| ユーザー |
まみめ
|
| 提出日時 | 2025-12-19 18:25:23 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| 記録 | |
| コンパイル時間 | 3,141 ms |
| コンパイル使用メモリ | 340,336 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2026-01-11 13:01:42 |
| 合計ジャッジ時間 | 3,958 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
void solve() {
int N;
cin >> N;
vector<string> S(N);
rep(i, N) { cin >> S[i]; }
int ans = 0;
auto dfs = [&](auto dfs, int r, int c, string str) -> void {
if (r == N - 1 && c == N - 1) {
string s = str.substr(0, N);
reverse(s.begin(), s.end());
string t = str.substr(0, N);
if (s == t) {
ans++;
}
return;
}
if (r + 1 < N) {
dfs(dfs, r + 1, c, str + S[r + 1][c]);
}
if (c + 1 < N) {
dfs(dfs, r, c + 1, str + S[r][c + 1]);
}
};
string str;
str.push_back(S[0][0]);
dfs(dfs, 0, 0, str);
cout << ans << endl;
}
int main() { solve(); }
まみめ