답안 #223197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223197 2020-04-15T04:56:55 Z jamielim Trener (COCI20_trener) C++14
55 / 110
2000 ms 7032 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD=1000000007;

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	char str[n][k][55];
	for(int i=0;i<n;i++){
		for(int j=0;j<k;j++){
			scanf("%s",str[i][j]);
		}
	}
	ll dp[n][k]; memset(dp,0,sizeof(dp));
	for(int i=0;i<k;i++)dp[n-1][i]=1;
	for(int i=n-2;i>=0;i--){
		for(int j=0;j<k;j++){
			for(int m=0;m<k;m++){
				bool f=1,s=1;
				for(int l=0;l<=i;l++){
					if(str[i][j][l]!=str[i+1][m][l]){f=0;break;}
				}
				if(!f){
					for(int l=0;l<=i;l++){
						if(str[i][j][l]!=str[i+1][m][l+1]){s=0;break;}
					}
				}
				if(f||s)dp[i][j]+=dp[i+1][m];
				dp[i][j]%=MOD;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<k;i++){ans+=dp[0][i];ans%=MOD;}
	printf("%lld",ans);
}

Compilation message

trener.cpp: In function 'int main()':
trener.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
trener.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%s",str[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 640 KB Output is correct
2 Correct 8 ms 640 KB Output is correct
3 Correct 8 ms 640 KB Output is correct
4 Correct 14 ms 640 KB Output is correct
5 Correct 13 ms 640 KB Output is correct
6 Correct 13 ms 640 KB Output is correct
7 Correct 14 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 8 ms 640 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 8 ms 640 KB Output is correct
8 Correct 14 ms 640 KB Output is correct
9 Correct 13 ms 640 KB Output is correct
10 Correct 13 ms 640 KB Output is correct
11 Correct 14 ms 640 KB Output is correct
12 Correct 506 ms 4864 KB Output is correct
13 Correct 499 ms 6912 KB Output is correct
14 Correct 508 ms 6960 KB Output is correct
15 Correct 504 ms 6912 KB Output is correct
16 Correct 1936 ms 7032 KB Output is correct
17 Execution timed out 2012 ms 6936 KB Time limit exceeded
18 Halted 0 ms 0 KB -