답안 #845358

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845358 2023-09-06T13:17:16 Z vjudge1 Trener (COCI20_trener) C++17
0 / 110
3 ms 3160 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
 
const int MOD = 1e9 + 7;

#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    #define OPEN freopen(".in", "r", stdin); \
                 freopen(".out", "w", stdout);
#else
    #define OPEN void(23);
#endif

string arr[55][1505];

bool check(string &a, string &b)
{
    int n = b.size(); 
    bool ok = true;
    for(int i = 2; i <= n -2 && ok; i++)
    {
        ok &= a[i -1] == b[i -1];
    }
    
    if(!ok) return false;
    if(a[0] == b[0]) return true;
    if(a[n -2] == b[n -1]) return true;
    return false;
}

void solve()
{
    int n, k; cin >> n >> k;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= k; j++)
            cin >> arr[i][j];

    int dp[k +1];
    fill(dp, dp + k +1, 1);
    for(int i = 1; i <= n -1; i++)
    {
        int *dp2 = new int[k +1];
        memset(dp2, 0, sizeof (dp2));
        for(int j = 1; j <= k; j++)
        {
            for(int c = 1; c <= k; c++)
            {
                if(check(arr[i][j], arr[i +1][c])) 
                    dp2[c] = (dp2[c] + dp[j]) % MOD;
            }
        }

        memcpy(dp, dp2, sizeof dp);
    }

    int cev = 0;
    for(int i = 1; i <= k; i++) cev = (cev + dp[i]) % MOD;

    cout << cev;

    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }
}

Compilation message

trener.cpp: In function 'void solve()':
trener.cpp:46:24: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   46 |         memset(dp2, 0, sizeof (dp2));
      |                        ^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -