Submission #845279

# Submission time Handle Problem Language Result Execution time Memory
845279 2023-09-06T12:57:19 Z vjudge1 Trener (COCI20_trener) C++17
55 / 110
2000 ms 5468 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll LOGN = 20;
const ll MAXN = 3e5 + 5;

vector<vector<string>> play;
vector<int> dp(1505);
bool check(string a, string b) {
	bool control1 = true;
	bool control2 = true;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i])
			control1 = false;
		if (a[i] != b[i+1])
			control2 = false;
	}

	return (control1 | control2);
}

int main() {
	fast
	int N, K;
	cin >> N >> K;

	play = vector<vector<string>>(N+1, vector<string>());
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < K; j++) {
			string s;
			cin >> s;
			play[i].push_back(s);
		}
	}

	for (int i = 0; i < play[N].size(); i++)
		dp[i] = 1;

	for (int i = N-1; i >= 1; i--) {
		vector<int> new_dp(1505);
		for (int str1 = 0; str1 < play[i].size(); str1++) {
			for (int str2 = 0; str2 < play[i+1].size(); str2++) {
				if (check(play[i][str1], play[i+1][str2]))
					new_dp[str1] = (new_dp[str1] + dp[str2]) % MOD; 
			}
		}
		dp = new_dp;
	}

	int ans = 0;
	for (int str = 0; str < play[1].size(); str++)
		ans = (ans + dp[str]) % MOD;
	cout << ans << "\n";
}

Compilation message

trener.cpp: In function 'bool check(std::string, std::string)':
trener.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < a.size(); i++) {
      |                  ~~^~~~~~~~~~
trener.cpp: In function 'int main()':
trener.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for (int i = 0; i < play[N].size(); i++)
      |                  ~~^~~~~~~~~~~~~~~~
trener.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int str1 = 0; str1 < play[i].size(); str1++) {
      |                      ~~~~~^~~~~~~~~~~~~~~~
trener.cpp:47:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |    for (int str2 = 0; str2 < play[i+1].size(); str2++) {
      |                       ~~~~~^~~~~~~~~~~~~~~~~~
trener.cpp:56:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for (int str = 0; str < play[1].size(); str++)
      |                    ~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 604 KB Output is correct
2 Correct 24 ms 604 KB Output is correct
3 Correct 25 ms 604 KB Output is correct
4 Correct 24 ms 600 KB Output is correct
5 Correct 24 ms 604 KB Output is correct
6 Correct 25 ms 604 KB Output is correct
7 Correct 24 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 25 ms 604 KB Output is correct
6 Correct 24 ms 604 KB Output is correct
7 Correct 25 ms 604 KB Output is correct
8 Correct 24 ms 600 KB Output is correct
9 Correct 24 ms 604 KB Output is correct
10 Correct 25 ms 604 KB Output is correct
11 Correct 24 ms 600 KB Output is correct
12 Execution timed out 2025 ms 5468 KB Time limit exceeded
13 Halted 0 ms 0 KB -