답안 #219375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219375 2020-04-05T08:07:43 Z Vimmer Trener (COCI20_trener) C++14
0 / 110
13 ms 512 KB
#include <bits/stdc++.h>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) ll(x.size())
#define pb push_back
#define N 75005
#define M ll(1e9 + 7)


using namespace std;

typedef long double ld;
typedef long long ll;
typedef short int si;




map <string, ll> dpl, dp;

int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, k;

    cin >> n >> k;

    vector <string> t(k), b(k);

    dp.clear(); dpl.clear();

    for (register int i = 0; i < k; i++) cin >> t[i];

    for (register int i = 0; i < k; i++) dpl[t[i]]++;

    for (register int i = 1; i < n; i++)
        {
            for (register int j = 0; j < k; j++)
            {
                string str, str1, str2;

                cin >> str;

                str1 = str.substr(0, i);

                str2 = str.substr(1);

                b[j] = str;

                ll sm = dpl[str1];

                if (str1 != str2) sm = (sm + dpl[str2]) % M;

                dp[str] = (dp[str] + sm) % M;
            }

            t = b;

            dpl = dp;

            dpl.clear();

            for (auto it : dp) dpl[it.F] = it.S;

            dp.clear();
        }

    ll ans = 0;

    for (register int i = 0; i < k; i++) ans = (ans + dpl[t[i]]) % M;

    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 4 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 512 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 12 ms 384 KB Output is correct
4 Incorrect 6 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 4 ms 384 KB Output isn't correct