# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223306 | 2020-04-15T07:01:51 Z | dantoh000 | Trener (COCI20_trener) | C++14 | 254 ms | 16120 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1000000007; int n,k; map<string,int> ct[55]; string a[55][1505]; 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]; } } ll ans = 0; ct[0][""]++; for (int i = 1; i <= n; i++){ for (int j = 1; j <= k; j++){ string X = a[i][j].substr(1,a[i][j].size()-1); string Y = a[i][j].substr(0,a[i][j].size()-1); //cout << a[i][j] << " " << X << " " << Y; int res = 0; if (ct[i-1].find(X) != ct[i-1].end()) res += ct[i-1][X]; if (X != Y && ct[i-1].find(Y) != ct[i-1].end()) res += ct[i-1][Y]; res %= mod; //printf("%d %d\n",ct[X],ct[Y]); ct[i][a[i][j]] += res; ct[i][a[i][j]] %= mod; } } for (auto x : ct[n]){ ans += x.second; } printf("%lld",ans%mod); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 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 | 23 ms | 3712 KB | Output is correct |
2 | Correct | 19 ms | 3712 KB | Output is correct |
3 | Correct | 19 ms | 3712 KB | Output is correct |
4 | Correct | 14 ms | 3200 KB | Output is correct |
5 | Correct | 20 ms | 3584 KB | Output is correct |
6 | Correct | 23 ms | 3712 KB | Output is correct |
7 | Correct | 15 ms | 3328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 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 | 23 ms | 3712 KB | Output is correct |
6 | Correct | 19 ms | 3712 KB | Output is correct |
7 | Correct | 19 ms | 3712 KB | Output is correct |
8 | Correct | 14 ms | 3200 KB | Output is correct |
9 | Correct | 20 ms | 3584 KB | Output is correct |
10 | Correct | 23 ms | 3712 KB | Output is correct |
11 | Correct | 15 ms | 3328 KB | Output is correct |
12 | Correct | 222 ms | 15096 KB | Output is correct |
13 | Correct | 236 ms | 16088 KB | Output is correct |
14 | Correct | 217 ms | 16120 KB | Output is correct |
15 | Correct | 227 ms | 16120 KB | Output is correct |
16 | Correct | 133 ms | 8056 KB | Output is correct |
17 | Correct | 254 ms | 14072 KB | Output is correct |
18 | Correct | 239 ms | 13816 KB | Output is correct |
19 | Correct | 243 ms | 13948 KB | Output is correct |
20 | Correct | 239 ms | 13816 KB | Output is correct |
21 | Correct | 246 ms | 13888 KB | Output is correct |
22 | Correct | 134 ms | 7800 KB | Output is correct |