結果
| 問題 |
No.2178 Payable Magic Items
|
| コンテスト | |
| ユーザー |
mine691
|
| 提出日時 | 2022-09-27 04:21:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,245 bytes |
| コンパイル時間 | 3,557 ms |
| コンパイル使用メモリ | 265,212 KB |
| 実行使用メモリ | 10,336 KB |
| 最終ジャッジ日時 | 2024-12-14 17:48:03 |
| 合計ジャッジ時間 | 8,627 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 3 |
| other | AC * 1 RE * 22 |
ソースコード
// 愚直高速化 unordered_set<<int> ver.
#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);
vector<int> d(N);
for (int i = 0; i < N; i++)
cin >> s[i];
vector<unordered_set<int>> st(32);
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; });
for (int i = 0; i < N; i++)
{
for (int j = 0; j < K; j++)
d[i] += abs(s[i][j] - 'D');
st[d[i]].insert(i);
}
int ans = 0;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < d[i]; j++)
{
vector<int> del;
for (auto &&l : st[j])
{
if (i == l)
continue;
int cnt = 0;
for (int k = 0; k < K; k++)
cnt += (s[i][k] <= s[l][k]);
if (cnt == K)
{
del.emplace_back(l);
ans++;
}
}
for (auto &&l : del)
st[j].erase(l);
}
}
cout << ans << "\n";
}
mine691