結果

問題 No.2178 Payable Magic Items
ユーザー mine691
提出日時 2022-09-27 03:33:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,032 bytes
コンパイル時間 2,642 ms
コンパイル使用メモリ 211,048 KB
最終ジャッジ日時 2025-02-07 16:52:25
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 10 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr static int mod = 1e9 + 7;
constexpr static int inf = (1 << 30) - 1;
constexpr static Int infll = (1LL << 61) - 1;
int Competitive_Programming = (ios_base::sync_with_stdio(false), cin.tie(nullptr), cout << fixed << setprecision(15), 0);

int main()
{
	int N, K;
	cin >> N >> K;
	vector<string> s(N);
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
	}

	set<string> st(s.begin(), s.end());

	sort(s.begin(), s.end(), [](string &a, string &b)
		 { 
					int ret1 = 0, ret2 = 0;
		for (int j = 0; j < a.size(); j++)
		{
			ret1 += abs(a[j] - 'D');
			ret2 += abs(b[j] - 'D');
		}
			return ret1 > ret2; });

	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		vector<string> del;
		for (auto &&t : st)
		{
			if (s[i] == t)
				continue;

			int cnt = 0;

			for (int k = 0; k < K; k++)
			{
				cnt += (s[i][k] <= t[k]);
			}

			if (cnt == K)
			{
				del.emplace_back(t);
				ans++;
			}
		}
		for (auto &&d : del)
			st.erase(d);
	}

	cout << ans << "\n";
}
0