# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223217 | 2020-04-15T05:24:23 Z | dantoh000 | Trener (COCI20_trener) | C++14 | 2000 ms | 6264 KB |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int n,k; int dp[2][1505]; string a[55][1505]; bool can(string a, string b){ return b.substr(1) == a || b.substr(0,b.size()-1) == a; } int main(){ scanf("%d%d",&n,&k); for (int i = 1; i <= n; i++){ for (int j = 1; j <= k; j++){ cin >> a[i][j]; } } for (int i = 1; i <= k; i++) dp[n&1][i] = 1; for (int i = n-1; i >= 1; i--){ for (int j = 1; j <= k; j++){ dp[i&1][j] = 0; for (int j2 = 1; j2 <= k; j2++){ if (can(a[i][j],a[i+1][j2])){ dp[i&1][j] += dp[1-i&1][j2]; dp[i&1][j] %= mod; } } } } int sum = 0; for (int i = 1; i <= k; i++) { sum += dp[1][i]; sum %= mod; } printf("%d",sum); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2944 KB | Output is correct |
2 | Correct | 6 ms | 2944 KB | Output is correct |
3 | Correct | 6 ms | 2944 KB | Output is correct |
4 | Correct | 6 ms | 2944 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 88 ms | 3192 KB | Output is correct |
2 | Correct | 97 ms | 3192 KB | Output is correct |
3 | Correct | 89 ms | 3192 KB | Output is correct |
4 | Correct | 73 ms | 3200 KB | Output is correct |
5 | Correct | 91 ms | 3192 KB | Output is correct |
6 | Correct | 95 ms | 3152 KB | Output is correct |
7 | Correct | 69 ms | 3192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2944 KB | Output is correct |
2 | Correct | 6 ms | 2944 KB | Output is correct |
3 | Correct | 6 ms | 2944 KB | Output is correct |
4 | Correct | 6 ms | 2944 KB | Output is correct |
5 | Correct | 88 ms | 3192 KB | Output is correct |
6 | Correct | 97 ms | 3192 KB | Output is correct |
7 | Correct | 89 ms | 3192 KB | Output is correct |
8 | Correct | 73 ms | 3200 KB | Output is correct |
9 | Correct | 91 ms | 3192 KB | Output is correct |
10 | Correct | 95 ms | 3152 KB | Output is correct |
11 | Correct | 69 ms | 3192 KB | Output is correct |
12 | Execution timed out | 2086 ms | 6264 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |