답안 #845286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845286 2023-09-06T12:59:22 Z vjudge1 Trener (COCI20_trener) C++17
0 / 110
13 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;
// bismillah
int main() {
  int N, K;
  cin >> N >> K;
  vector<map<string, int>> cnt(N);
  for (int i = 0;i < N; ++i) {
    for (int j = 0;j < K; ++j) {
      string s;
      cin >> s;
      cnt[i][s] += 1;
    }
  }
  int64_t mod = 1e9+7;
  map<string, int64_t> dp;
  for (int i = N-1;i >= 0; --i) {
    for (auto [s, c] : cnt[i]) {
      if (i == N-1) {
        dp[s] = c;
      }
      string a = s;
      string b = s;
      reverse(b.begin(), b.end());
      a.pop_back();
      b.pop_back();
      reverse(b.begin(), b.end());
      dp[a] += c * dp[s];
      if (a != b) dp[b] += c * dp[s];
      dp[a] %= mod;
      dp[b] %= mod;
    }
  }
  int64_t ans = 0;
  for (auto [s, c] : cnt[0]) {
    ans += dp[s] * c;
    ans %= mod;
  }
  cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1884 KB Output is correct
2 Correct 13 ms 1880 KB Output is correct
3 Correct 11 ms 1884 KB Output is correct
4 Incorrect 3 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -