답안 #845266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845266 2023-09-06T12:54:06 Z vjudge1 Trener (COCI20_trener) C++17
0 / 110
23 ms 604 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(1305);
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 = 1; i <= N; i++) {
		sort(play[i].begin(), play[i].end());
		play[i].erase(unique(play[i].begin(), play[i].end()), play[i].end());
	}

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

	for (int i = N-1; i >= 1; i--) {
		vector<int> new_dp(1305);
		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:46: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]
   46 |  for (int i = 0; i < play[N].size(); i++)
      |                  ~~^~~~~~~~~~~~~~~~
trener.cpp:51: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]
   51 |   for (int str1 = 0; str1 < play[i].size(); str1++) {
      |                      ~~~~~^~~~~~~~~~~~~~~~
trener.cpp:52: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]
   52 |    for (int str2 = 0; str2 < play[i+1].size(); str2++) {
      |                       ~~~~~^~~~~~~~~~~~~~~~~~
trener.cpp:61: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]
   61 |  for (int str = 0; str < play[1].size(); str++)
      |                    ~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 23 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -