답안 #445206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445206 2021-07-16T20:31:08 Z Abrar_Al_Samit Trener (COCI20_trener) C++17
0 / 110
8 ms 1740 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define debug(x) cerr << '[' << (#x) << "] = " << x << '\n';

template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update> ;

const int Mod = 1e9 + 7;

void PlayGround() {
    int n, k; cin >> n >> k;
    vector<vector<string>>buck(n, vector<string>(k));
    for(int i=0; i<n; ++i) {
        for(auto& it : buck[i]) 
            cin >> it;
    }
    
    map<string,int>dp[n];
    int ans = 0;
    for(int i=0; i<k; ++i) dp[0][buck[0][i]] = 1;
    for(int i=1; i<n; ++i) {
        for(int j=0; j<k; ++j) {
            string s = buck[i][j];
            if(s.substr(0, i)!=s.substr(1, i)) dp[i][s] = (dp[i][s] + dp[i-1][s.substr(0, i)]) % Mod;
            dp[i][s] = (dp[i][s] + dp[i-1][s.substr(1, i)]) % Mod;
            if(i==n-1) ans = (ans + dp[i][s]) % Mod;
        }
    }
    cout << ans << '\n';

    #ifndef ONLINE_JUDGE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
} 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGE
     //   freopen("input.txt", "r", stdin);
   // #endif
    PlayGround();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -