답안 #845207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845207 2023-09-06T12:36:33 Z vjudge1 Trener (COCI20_trener) C++17
0 / 110
11 ms 1372 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, int> dp;
	for(int j=0; j<k; j++){
		string s;
		cin>>s;
		dp[s]=1;
	}
	for(int i=1; i<n; i++){
		ans=0;
		for(int j=0; j<k; j++){
			string s;
			cin>>s;

			string a(s.begin(), s.end()-1), b(s.begin()+1, s.end());
			if(a==b) dp[s]=dp[a];
			else dp[s]=(dp[a]+dp[b])%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 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -