# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
845300 | vjudge1 | Trener (COCI20_trener) | C++17 | 2037 ms | 18512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll LOGN = 20;
const ll MAXN = 3e5 + 5;
vector<vector<string>> play;
map<string,int> dp;
int main() {
fast
int N, K;
cin >> N >> K;
play = vector<vector<string>>(N+1, vector<string>());
for (int i = 1; i <= N; i++) {
for (int j = 0; j < K; j++) {
string s;
cin >> s;
play[i].push_back(s);
}
}
for (int i = 0; i < play[N].size(); i++)
dp[play[N][i]]++;
for (int i = N-1; i >= 1; i--) {
map<string,int> new_dp;
for (int s1 = 0; s1 < play[i].size(); s1++) {
for (char ch = 'a'; ch <= 'z'; ch++) {
string str1 = play[i][s1];
new_dp[str1] = (new_dp[str1] + dp[str1 + ch]) % MOD;
if (str1 + ch != ch + str1)
new_dp[str1] = (new_dp[str1] + dp[ch + str1]) % MOD;
}
}
dp = new_dp;
}
int ans = 0;
for (auto u : dp)
ans = (ans + u.s) % MOD;
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |