답안 #250878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250878 2020-07-19T10:40:48 Z 44442 Trener (COCI20_trener) C++11
110 / 110
390 ms 35064 KB
#include<bits/stdc++.h>
using namespace std;
long long n,k,ok[104][1504],mod,okk;
string str[104][1504],x,y;
map<string,long long>m,num;
set<string>ss;
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n>>k;
for(int i=1;i<n+1;i++){
	 for(int j=1;j<k+1;j++){
	 	 cin>>str[i][j];
	 	 ss.insert(str[i][j]);
	 	 m[str[i][j]]=j;
	 	 num[str[i][j]]++;
	 }
}
for(int i=1;i<k+1;i++){
	 ok[1][i]=1;
}
mod=1e9+7;
set<string>::iterator itt;
for(int i=2;i<n+1;i++){
	 for(int j=1;j<k+1;j++){
	 	 x.clear();
	 	 for(int ii=0;ii<i-1;ii++){
	 	 	 x.push_back(str[i][j][ii]);
	     }
	 	 itt=ss.find(x);
	 	 if(itt!=ss.end()){
	 	 	 ok[i][j]+=(num[x]*ok[i-1][m[x]])%mod;
		 }
		 y.clear();
		 for(int ii=1;ii<i;ii++){
		 	 y.push_back(str[i][j][ii]);
		 }
		 itt=ss.find(y);
		 if(itt!=ss.end() and x!=y){
		 	 ok[i][j]+=(num[y]*ok[i-1][m[y]])%mod;
		 }
		 //cout<<str[i][j]<<ok[i][j]<<endl;
	 }
} 
for(int i=1;i<k+1;i++){
	 //cout<<okk<<endl;
	 okk=(okk+ok[n][i])%mod;
}
cout<<okk;
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 3 ms 5248 KB Output is correct
4 Correct 3 ms 5248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 7424 KB Output is correct
2 Correct 19 ms 7404 KB Output is correct
3 Correct 20 ms 7424 KB Output is correct
4 Correct 8 ms 5760 KB Output is correct
5 Correct 20 ms 7040 KB Output is correct
6 Correct 19 ms 7040 KB Output is correct
7 Correct 10 ms 5760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 3 ms 5248 KB Output is correct
4 Correct 3 ms 5248 KB Output is correct
5 Correct 20 ms 7424 KB Output is correct
6 Correct 19 ms 7404 KB Output is correct
7 Correct 20 ms 7424 KB Output is correct
8 Correct 8 ms 5760 KB Output is correct
9 Correct 20 ms 7040 KB Output is correct
10 Correct 19 ms 7040 KB Output is correct
11 Correct 10 ms 5760 KB Output is correct
12 Correct 379 ms 34936 KB Output is correct
13 Correct 381 ms 35064 KB Output is correct
14 Correct 387 ms 35064 KB Output is correct
15 Correct 390 ms 35020 KB Output is correct
16 Correct 62 ms 10488 KB Output is correct
17 Correct 352 ms 28536 KB Output is correct
18 Correct 366 ms 28792 KB Output is correct
19 Correct 379 ms 28792 KB Output is correct
20 Correct 367 ms 28664 KB Output is correct
21 Correct 390 ms 28704 KB Output is correct
22 Correct 67 ms 10616 KB Output is correct