이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mod 1000000007
#define N 55
#define K 15005
string kelime[N][K];
ll int kactaneyol[N][K];
int main(){
lalala;
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
string a;cin>>a;
kelime[i][j]=a;
}
}
for(int i=0;i<k;i++)kactaneyol[0][i]=1;
for(int i=0;i<n-1;i++){
for(int j=0;j<k;j++){
//cout<<kactaneyol[i][j]<<" ";
string str=kelime[i][j];
for(int jx=0;jx<k;jx++){
string s=kelime[i+1][jx][0]+str, t=str+kelime[i+1][jx][i+1];
if(s==kelime[i+1][jx]|| t==kelime[i+1][jx] ){
kactaneyol[i+1][jx]+=kactaneyol[i][j];
kactaneyol[i+1][jx]%=mod;
}
}
}//cout<<endl;
}
ll int cev=0;
for(int i=0;i<k;i++){
//cout<<kactaneyol[n-1][i]<<" ";
cev+=kactaneyol[n-1][i];
cev%=mod;
}
cout<<cev<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |