Submission #31181683


Source Code Expand

Copy
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;
int n, m;
string arr[20];
vector<string> v;
int ans;
int check()
{
int i, j, k;
int cnt;
int ret = 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;

int n, m;
string arr[20];
vector<string> v;
int ans;

int check()
{
	int i, j, k;
	int cnt;
	int ret = 0;

	for (i = 'a'; i <= 'z'; i++)
	{
		cnt = 0;
		for (j = 0; j < v.size(); j++)
		{
			for (k = 0; k < v[j].length(); k++)
			{
				if (v[j][k] == i)
				{
					cnt++;
					break;
				}
			}
		}

		ret += (cnt == m);
	}

	return ret;
}

void recur(int cur, int cnt)
{
	if (cur == n)
	{
		ans = max(ans, check());

		return;
	}

	v.push_back(arr[cur]);
	recur(cur + 1, cnt + 1);
	v.pop_back();
	recur(cur + 1, cnt);
}

int main()
{
	int i;

	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	recur(0, 0);

	cout << ans;
}

Submission Info

Submission Time
Task C - Just K
User gojib2002
Language C++ (GCC 9.2.1)
Score 300
Code Size 883 Byte
Status AC
Exec Time 98 ms
Memory 3600 KB

Compile Error

./Main.cpp: In function ‘int check()’:
./Main.cpp:26:17: 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]
   26 |   for (j = 0; j < v.size(); j++)
      |               ~~^~~~~~~~~~
./Main.cpp:28:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   28 |    for (k = 0; k < v[j].length(); k++)
      |                ~~^~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 19
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt
Case Name Status Exec Time Memory
example_00.txt AC 8 ms 3436 KB
example_01.txt AC 2 ms 3460 KB
example_02.txt AC 2 ms 3464 KB
test_00.txt AC 2 ms 3596 KB
test_01.txt AC 4 ms 3544 KB
test_02.txt AC 2 ms 3460 KB
test_03.txt AC 11 ms 3468 KB
test_04.txt AC 71 ms 3396 KB
test_05.txt AC 2 ms 3600 KB
test_06.txt AC 3 ms 3360 KB
test_07.txt AC 13 ms 3464 KB
test_08.txt AC 3 ms 3520 KB
test_09.txt AC 9 ms 3564 KB
test_10.txt AC 95 ms 3428 KB
test_11.txt AC 98 ms 3460 KB
test_12.txt AC 96 ms 3504 KB
test_13.txt AC 98 ms 3464 KB
test_14.txt AC 95 ms 3468 KB
test_15.txt AC 83 ms 3568 KB


2025-03-17 (Mon)
07:43:48 +00:00