답안 #845225

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845225 2023-09-06T12:41:17 Z vjudge1 Trener (COCI20_trener) C++17
110 / 110
303 ms 32252 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()
const int mod=1e9+7;

int main(){
	int n, k;
	cin>>n>>k;


	int ans;
	map<string, ll> dp, cnt;
	for(int j=0; j<k; j++){
		string s;
		cin>>s;
		dp[s]=1;
		cnt[s]++;
	}
	for(int i=1; i<n; i++){
		ans=0;
		for(int j=0; j<k; j++){
			string s;
			cin>>s;

			cnt[s]++;
			string a(s.begin(), s.end()-1), b(s.begin()+1, s.end());
			if(a==b) dp[s]=dp[a]*cnt[a]%mod;
			else dp[s]=(dp[a]*cnt[a]%mod+dp[b]*cnt[b]%mod)%mod;
			ans=(ans+dp[s])%mod;
		}
	}
	cout<<ans<<endl;

}

Compilation message

trener.cpp: In function 'int main()':
trener.cpp:5:14: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
    5 | #define endl "\n"
      |              ^~~~
trener.cpp:14:6: note: 'ans' was declared here
   14 |  int ans;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2420 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 13 ms 2400 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 11 ms 1884 KB Output is correct
6 Correct 11 ms 1800 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 13 ms 2420 KB Output is correct
6 Correct 16 ms 2396 KB Output is correct
7 Correct 13 ms 2400 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 11 ms 1884 KB Output is correct
10 Correct 11 ms 1800 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Correct 282 ms 32252 KB Output is correct
13 Correct 293 ms 32040 KB Output is correct
14 Correct 276 ms 32192 KB Output is correct
15 Correct 303 ms 32080 KB Output is correct
16 Correct 51 ms 344 KB Output is correct
17 Correct 224 ms 21588 KB Output is correct
18 Correct 247 ms 21844 KB Output is correct
19 Correct 244 ms 21584 KB Output is correct
20 Correct 229 ms 21588 KB Output is correct
21 Correct 236 ms 21588 KB Output is correct
22 Correct 55 ms 436 KB Output is correct