답안 #845272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845272 2023-09-06T12:55:37 Z vjudge1 Trener (COCI20_trener) C++17
110 / 110
173 ms 21484 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007

using namespace std;





void solve(){
    int n,k; cin >> n >> k;
    string arr[n+1][k+1];
    for(int i=1; i<=n; i++){
        for(int j=1; j<=k; j++) cin >> arr[i][j];
    }
    map<string, int> see;
    for(int L=n; L>=2; L--){
        for(int i=1; i<=k; i++){
            string s=arr[L][i];
            if(L==n) see[s]=1;
            see[s.substr(0, L-1)]+=see[s];
            if(s.substr(0, L-1) != s.substr(1, L-1))see[s.substr(1, L-1)]+=see[s];
            see[s.substr(0, L-1)]%=MOD;
            see[s.substr(1, L-1)]%=MOD;
            //cerr << s spc "to" spc s.substr(0, L-1) spc s.substr(1, L-1) spc see[s] << endl;
        }
    }
    int ans=0;
    for(int i=1; i<=k; i++){
        //cerr << arr[1][i] spc see[arr[1][i]] << endl;
        ans+=see[arr[1][i]];
        ans%=MOD;
    }
    cout << ans << endl;
}



signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out","w",stdout);
    #endif
    

    ll t=1;
    //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1628 KB Output is correct
2 Correct 8 ms 1628 KB Output is correct
3 Correct 8 ms 1624 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 7 ms 1372 KB Output is correct
6 Correct 7 ms 1508 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 1628 KB Output is correct
6 Correct 8 ms 1628 KB Output is correct
7 Correct 8 ms 1624 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 7 ms 1372 KB Output is correct
10 Correct 7 ms 1508 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 173 ms 21224 KB Output is correct
13 Correct 162 ms 21328 KB Output is correct
14 Correct 163 ms 21484 KB Output is correct
15 Correct 163 ms 21392 KB Output is correct
16 Correct 26 ms 5464 KB Output is correct
17 Correct 148 ms 15952 KB Output is correct
18 Correct 134 ms 16268 KB Output is correct
19 Correct 139 ms 16112 KB Output is correct
20 Correct 139 ms 16256 KB Output is correct
21 Correct 141 ms 16100 KB Output is correct
22 Correct 30 ms 5468 KB Output is correct