Submission #845477

# Submission time Handle Problem Language Result Execution time Memory
845477 2023-09-06T13:48:23 Z vjudge1 Trener (COCI20_trener) C++17
0 / 110
409 ms 800 KB
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define CDIV(a,b) (((a)+(b)-(1))/(b))
const ll inf = 1e17 + 5;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 30;

 
int mod_(int a, int b)
{
    if(a >= 0)return a % b;
    a += (-a/b + 1) * b;
    return a % b;
}

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<vector<string> >v(n, vector<string>(k));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < k; ++j)
            cin >> v[i][j];
    }
    vector<vector<int> >dp(n, vector<int>(k));
    for(int i = k - 1; i >= 0; --i)dp[n - 1][i] = 1;
    for(int i = n - 1; i >= 1; --i)
    {
        for(int j = 0; j < k; ++j)
        {
            for(int z = 0; z < k; ++z)
            {
                string cmp1 = v[i][j], cmp2 = v[i - 1][z];
                for(int er = 0; er <= i; ++er)
                {
                    string tmp = cmp1;
                    tmp.erase(tmp.begin() + er);
                    if(tmp == cmp2)
                    {
                        //cout << cmp1 << ' ' << tmp << ' ' << cmp2 << endl;
                        dp[i - 1][z] += dp[i][j];
                        break;
                    }
                }
            }
        }
    }
    cout << accumulate(dp[0].begin(), dp[0].end(), 0) << endl;

}
    

int main()
{
    fio;
    //int t; cin >> t; while(t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 409 ms 800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -